Class: Ebay::Schema::Node
- Inherits:
-
Object
- Object
- Ebay::Schema::Node
- Includes:
- Inflections
- Defined in:
- lib/ebay/schema/mapper/node.rb
Constant Summary
Constant Summary
Constants included from Inflections
Inflections::DOWNCASE_TOKENS, Inflections::NAME_MAPPINGS, Inflections::UPCASE_TOKENS
Instance Attribute Summary (collapse)
-
- (Object) max
Returns the value of attribute max.
-
- (Object) min
Returns the value of attribute min.
-
- (Object) name
Returns the value of attribute name.
Instance Method Summary (collapse)
- - (Object) accessor_name
- - (Object) declaration
-
- (Node) initialize(name, attributes = {})
constructor
A new instance of Node.
- - (Boolean) optional?
- - (Object) xml_mapping_node_type
Methods included from Inflections
#downcase_first_character, #ebay_camelize, #ebay_underscore, #underscore, #upcase_first_character
Constructor Details
- (Node) initialize(name, attributes = {})
A new instance of Node
8 9 10 11 12 13 14 15 |
# File 'lib/ebay/schema/mapper/node.rb', line 8 def initialize(name, attributes = {}) @name = name @type = attributes[:type] @min = attributes[:min] || "1" @max = attributes[:max] || "1" @field = attributes[:field] @child = attributes[:child] end |
Instance Attribute Details
- (Object) max
Returns the value of attribute max
7 8 9 |
# File 'lib/ebay/schema/mapper/node.rb', line 7 def max @max end |
- (Object) min
Returns the value of attribute min
7 8 9 |
# File 'lib/ebay/schema/mapper/node.rb', line 7 def min @min end |
- (Object) name
Returns the value of attribute name
7 8 9 |
# File 'lib/ebay/schema/mapper/node.rb', line 7 def name @name end |
Instance Method Details
- (Object) accessor_name
21 22 23 24 25 26 27 28 29 |
# File 'lib/ebay/schema/mapper/node.rb', line 21 def accessor_name name = ebay_underscore(@name) if name =~ /_array$/ name.gsub!(/_array$/, '') Inflector.pluralize(name) else name end end |
- (Object) declaration
35 36 37 |
# File 'lib/ebay/schema/mapper/node.rb', line 35 def declaration "#{xml_mapping_node_type} :#{accessor_name}" end |
- (Boolean) optional?
17 18 19 |
# File 'lib/ebay/schema/mapper/node.rb', line 17 def optional? @min == "0" end |
- (Object) xml_mapping_node_type
31 32 33 |
# File 'lib/ebay/schema/mapper/node.rb', line 31 def xml_mapping_node_type override_type || Inflector.demodulize(self.class.to_s).underscore end |