Class: Rets::Metadata::RetsClass
- Inherits:
-
Object
- Object
- Rets::Metadata::RetsClass
- Defined in:
- lib/rets/metadata/rets_class.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#tables ⇒ Object
Returns the value of attribute tables.
Class Method Summary collapse
- .build(rets_class_fragment, resource, metadata) ⇒ Object
- .find_table_container(metadata, resource, rets_class) ⇒ Object
Instance Method Summary collapse
- #find_table(name) ⇒ Object
-
#initialize(rets_class_fragment, resource) ⇒ RetsClass
constructor
A new instance of RetsClass.
- #print_tree ⇒ Object
Constructor Details
#initialize(rets_class_fragment, resource) ⇒ RetsClass
Returns a new instance of RetsClass.
8 9 10 11 12 |
# File 'lib/rets/metadata/rets_class.rb', line 8 def initialize(rets_class_fragment, resource) self.resource = resource self.tables = [] self.name = rets_class_fragment["ClassName"] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/rets/metadata/rets_class.rb', line 5 def name @name end |
#resource ⇒ Object
Returns the value of attribute resource.
6 7 8 |
# File 'lib/rets/metadata/rets_class.rb', line 6 def resource @resource end |
#tables ⇒ Object
Returns the value of attribute tables.
4 5 6 |
# File 'lib/rets/metadata/rets_class.rb', line 4 def tables @tables end |
Class Method Details
.build(rets_class_fragment, resource, metadata) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rets/metadata/rets_class.rb', line 18 def self.build(rets_class_fragment, resource, ) rets_class = new(rets_class_fragment, resource) table_container = find_table_container(, resource, rets_class) if table_container table_container.tables.each do |table_fragment| rets_class.tables << TableFactory.build(table_fragment, resource) end end rets_class end |
.find_table_container(metadata, resource, rets_class) ⇒ Object
14 15 16 |
# File 'lib/rets/metadata/rets_class.rb', line 14 def self.find_table_container(, resource, rets_class) [:table].detect { |t| t.resource == resource.id && t.class == rets_class.name } end |
Instance Method Details
#find_table(name) ⇒ Object
37 38 39 |
# File 'lib/rets/metadata/rets_class.rb', line 37 def find_table(name) tables.detect { |value| value.name == name } end |
#print_tree ⇒ Object
32 33 34 35 |
# File 'lib/rets/metadata/rets_class.rb', line 32 def print_tree puts " Class: #{name}" tables.each(&:print_tree) end |