Class: Rets::Metadata::RetsClass
- Inherits:
-
Object
- Object
- Rets::Metadata::RetsClass
- Defined in:
- lib/rets/metadata/rets_class.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#tables ⇒ Object
Returns the value of attribute tables.
-
#visible_name ⇒ Object
Returns the value of attribute visible_name.
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.
10 11 12 13 14 15 16 |
# File 'lib/rets/metadata/rets_class.rb', line 10 def initialize(rets_class_fragment, resource) self.resource = resource self.tables = [] self.name = rets_class_fragment["ClassName"] self.visible_name = rets_class_fragment["VisibleName"] self.description = rets_class_fragment["Description"] end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/rets/metadata/rets_class.rb', line 7 def description @description end |
#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.
8 9 10 |
# File 'lib/rets/metadata/rets_class.rb', line 8 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 |
#visible_name ⇒ Object
Returns the value of attribute visible_name.
6 7 8 |
# File 'lib/rets/metadata/rets_class.rb', line 6 def visible_name @visible_name end |
Class Method Details
.build(rets_class_fragment, resource, metadata) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rets/metadata/rets_class.rb', line 22 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
18 19 20 |
# File 'lib/rets/metadata/rets_class.rb', line 18 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
43 44 45 |
# File 'lib/rets/metadata/rets_class.rb', line 43 def find_table(name) tables.detect { |value| value.name == name } end |
#print_tree ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rets/metadata/rets_class.rb', line 36 def print_tree puts " Class: #{name}" puts " Visible Name: #{visible_name}" puts " Description : #{description}" tables.each(&:print_tree) end |