Class/Module Index [+]

Quicksearch

CIMI::Model::Schema::Scalar

Public Class Methods

new(name, opts) click to toggle source
# File lib/cimi/model/schema.rb, line 50
def initialize(name, opts)
  @text = opts[:text]
  if ! [nil, :nested, :direct].include?(@text)
    raise "text option for scalar must be :nested or :direct"
  end
  super(name, opts)
end

Public Instance Methods

from_xml(xml, model) click to toggle source
# File lib/cimi/model/schema.rb, line 62
def from_xml(xml, model)
  case @text
    when :nested then model[@name] = xml[@xml_name].first["content"] if xml[@xml_name]
    when :direct then model[@name] = xml["content"]
    else model[@name] = xml[@xml_name]
  end
end
nested_text?() click to toggle source
# File lib/cimi/model/schema.rb, line 60
def nested_text?; @text == :nested; end
text?() click to toggle source
# File lib/cimi/model/schema.rb, line 58
def text?; @text; end
to_xml(model, xml) click to toggle source
# File lib/cimi/model/schema.rb, line 70
def to_xml(model, xml)
  return unless model
  return unless model[@name]
  case @text
    when :nested then xml[@xml_name] = [{ "content" => model[@name] }]
    when :direct then xml["content"] = model[@name]
    else xml[@xml_name] = model[@name]
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.