Class: Rets::Metadata::RetsClass
- Inherits:
-
Object
- Object
- Rets::Metadata::RetsClass
- Defined in:
- lib/rets/metadata/rets_class.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#standard_name ⇒ Object
readonly
Returns the value of attribute standard_name.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
-
#visible_name ⇒ Object
readonly
Returns the value of attribute visible_name.
Class Method Summary collapse
- .build(rets_class_fragment, resource_id, lookup_types, metadata) ⇒ Object
- .builds_tables(table_container, resource_id, lookup_types) ⇒ Object
- .find_table_container(metadata, resource_id, class_name) ⇒ Object
Instance Method Summary collapse
- #find_table(name) ⇒ Object
-
#initialize(name, visible_name, standard_name, description, tables) ⇒ RetsClass
constructor
A new instance of RetsClass.
-
#print_tree(out = $stdout) ⇒ Object
Print the tree to a file.
Constructor Details
#initialize(name, visible_name, standard_name, description, tables) ⇒ RetsClass
Returns a new instance of RetsClass.
6 7 8 9 10 11 12 13 |
# File 'lib/rets/metadata/rets_class.rb', line 6 def initialize(name, visible_name, standard_name, description, tables) @name = name @visible_name = visible_name @description = description @standard_name = standard_name @tables = tables end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'lib/rets/metadata/rets_class.rb', line 4 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/rets/metadata/rets_class.rb', line 4 def name @name end |
#standard_name ⇒ Object (readonly)
Returns the value of attribute standard_name.
4 5 6 |
# File 'lib/rets/metadata/rets_class.rb', line 4 def standard_name @standard_name end |
#tables ⇒ Object (readonly)
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 (readonly)
Returns the value of attribute visible_name.
4 5 6 |
# File 'lib/rets/metadata/rets_class.rb', line 4 def visible_name @visible_name end |
Class Method Details
.build(rets_class_fragment, resource_id, lookup_types, metadata) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rets/metadata/rets_class.rb', line 29 def self.build(rets_class_fragment, resource_id, lookup_types, ) class_name = rets_class_fragment["ClassName"] visible_name = rets_class_fragment["VisibleName"] standard_name = rets_class_fragment["StandardName"] description = rets_class_fragment["Description"] table_container = find_table_container(, resource_id, class_name) tables = builds_tables(table_container, resource_id, lookup_types) new(class_name, visible_name, standard_name, description, tables) end |
.builds_tables(table_container, resource_id, lookup_types) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/rets/metadata/rets_class.rb', line 19 def self.builds_tables(table_container, resource_id, lookup_types) if table_container table_container.tables.map do |table_fragment| TableFactory.build(table_fragment, resource_id, lookup_types) end else [] end end |
.find_table_container(metadata, resource_id, class_name) ⇒ Object
15 16 17 |
# File 'lib/rets/metadata/rets_class.rb', line 15 def self.find_table_container(, resource_id, class_name) [:table].detect { |t| t.resource == resource_id && t.class == class_name } end |
Instance Method Details
#find_table(name) ⇒ Object
52 53 54 |
# File 'lib/rets/metadata/rets_class.rb', line 52 def find_table(name) tables.detect { |value| value.name.downcase == name.downcase } end |
#print_tree(out = $stdout) ⇒ Object
Print the tree to a file
- out
-
The file to print to. Defaults to $stdout.
43 44 45 46 47 48 49 50 |
# File 'lib/rets/metadata/rets_class.rb', line 43 def print_tree(out = $stdout) out.puts "## Class: #{name}" out.puts " Visible Name: #{visible_name}" out.puts " Description : #{description}" tables.each do |table| table.print_tree(out) end end |