Class: SAXMachine::SAXConfig::AttributeConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/sax-machine/sax_attribute_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ AttributeConfig

Returns a new instance of AttributeConfig.



7
8
9
10
11
12
# File 'lib/sax-machine/sax_attribute_config.rb', line 7

def initialize(name, options)
  @name = name.to_s
  @as = options[:as]
  @setter = "#{@as}="
  @required = options[:required]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/sax-machine/sax_attribute_config.rb', line 5

def name
  @name
end

#setterObject (readonly)

Returns the value of attribute setter.



5
6
7
# File 'lib/sax-machine/sax_attribute_config.rb', line 5

def setter
  @setter
end

Instance Method Details

#attrs_match?(attrs) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/sax-machine/sax_attribute_config.rb', line 26

def attrs_match?(attrs)
  attrs.index(@name) ? true : false
end

#collection?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/sax-machine/sax_attribute_config.rb', line 34

def collection?
  false
end

#columnObject



14
15
16
# File 'lib/sax-machine/sax_attribute_config.rb', line 14

def column
  @as || @name.to_sym
end

#has_value_and_attrs_match?(attrs) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/sax-machine/sax_attribute_config.rb', line 30

def has_value_and_attrs_match?(attrs)
  attrs_match?(attrs)
end

#required?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/sax-machine/sax_attribute_config.rb', line 18

def required?
  @required
end

#value_from_attrs(attrs) ⇒ Object



22
23
24
# File 'lib/sax-machine/sax_attribute_config.rb', line 22

def value_from_attrs(attrs)
  attrs.index(@name) ? attrs[attrs.index(@name) + 1] : nil
end