class Rets::Metadata::LookupTable

Attributes

long_name[R]
lookup_types[R]
name[R]
resource_id[R]
table_fragment[R]

Public Class Methods

build(table_fragment, resource_id, lookup_types) click to toggle source
# File lib/rets/metadata/lookup_table.rb, line 15
def self.build(table_fragment, resource_id, lookup_types)
  lookup_name = table_fragment["LookupName"]
  lookup_types = lookup_types[lookup_name]
  new(resource_id, lookup_types, table_fragment)
end
new(resource_id, lookup_types, table_fragment) click to toggle source
# File lib/rets/metadata/lookup_table.rb, line 6
def initialize(resource_id, lookup_types, table_fragment)
  @resource_id = resource_id
  @lookup_types = lookup_types

  @table_fragment = table_fragment
  @name = table_fragment["SystemName"]
  @long_name = table_fragment["LongName"]
end

Public Instance Methods

lookup_type(value) click to toggle source
# File lib/rets/metadata/lookup_table.rb, line 40
def lookup_type(value)
  lookup_types.detect {|lt| lt.value == value }
end
print_tree(out = $stdout) click to toggle source

Print the tree to a file

out

The file to print to. Defaults to $stdout.

resolve(value) click to toggle source
# File lib/rets/metadata/lookup_table.rb, line 44
def resolve(value)
  if value.empty?
    return value.to_s.strip
  end

  #Remove surrounding quotes
  clean_value  = value.scan(/^["']?(.*?)["']?$/).join


  lookup_type = lookup_type(clean_value)

  resolved_value = lookup_type ? lookup_type.long_value : nil

  if resolved_value.nil? && $VERBOSE
    warn("Discarding unmappable value of #{clean_value.inspect}")
  end

  resolved_value.to_s.strip
end