Class: Xommelier::Xml::Element::Structure::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/xommelier/xml/element/structure/property.rb

Direct Known Subclasses

Attribute, Element, Text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ Property

Returns a new instance of Property.



13
14
15
16
# File 'lib/xommelier/xml/element/structure/property.rb', line 13

def initialize(name, options)
  @name = name
  @options = self.class.const_get(:DEFAULTS).merge(options)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/xommelier/xml/element/structure/property.rb', line 18

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



18
19
20
# File 'lib/xommelier/xml/element/structure/property.rb', line 18

def options
  @options
end

Instance Method Details

#complex_type?Boolean

Returns:



38
39
40
# File 'lib/xommelier/xml/element/structure/property.rb', line 38

def complex_type?
  type < Xml::Element
end

#defaultObject



29
30
31
# File 'lib/xommelier/xml/element/structure/property.rb', line 29

def default
  options[:default]
end

#default?true, false

Returns has default value?.

Returns:

  • (true, false)

    has default value?



43
44
45
# File 'lib/xommelier/xml/element/structure/property.rb', line 43

def default?
  options.key?(:default) && required?
end

#inspectObject



47
48
49
# File 'lib/xommelier/xml/element/structure/property.rb', line 47

def inspect
  "#<Xommelier::X::E::S::#{self.class.name.demodulize}:0x#{object_id.to_s(16)} #{instance_variables.map { |ivar| "#{ivar}=#{instance_variable_get(ivar).inspect}" }.join(' ')}>"
end

#nsXommelier::Xml::Namespace



25
26
27
# File 'lib/xommelier/xml/element/structure/property.rb', line 25

def ns
  options[:ns]
end

#typeClass

Returns:

  • (Class)


34
35
36
# File 'lib/xommelier/xml/element/structure/property.rb', line 34

def type
  options[:type]
end

#writerObject



20
21
22
# File 'lib/xommelier/xml/element/structure/property.rb', line 20

def writer
  @writer ||= "#{name}="
end