Class: Rets::Metadata::RetsClass

Inherits:
Object
  • Object
show all
Defined in:
lib/rets/metadata/rets_class.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/rets/metadata/rets_class.rb', line 5

def name
  @name
end

#resourceObject

Returns the value of attribute resource.



6
7
8
# File 'lib/rets/metadata/rets_class.rb', line 6

def resource
  @resource
end

#tablesObject

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


32
33
34
35
# File 'lib/rets/metadata/rets_class.rb', line 32

def print_tree
  puts "  Class: #{name}"
  tables.each(&:print_tree)
end