Class: VoteSmart::Office::Type

Inherits:
Common
  • Object
show all
Defined in:
lib/vote_smart/office.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Common

construct_url, get_json_data, hash2get, #initialize, parallelize!, request, response_child, session, set_attribute_map, #update_attributes

Constructor Details

This class inherits a constructor from VoteSmart::Common

Instance Attribute Details

#branch_idObject

Returns the value of attribute branch_id.



91
92
93
# File 'lib/vote_smart/office.rb', line 91

def branch_id
  @branch_id
end

#idObject

Returns the value of attribute id.



91
92
93
# File 'lib/vote_smart/office.rb', line 91

def id
  @id
end

#level_idObject

Returns the value of attribute level_id.



91
92
93
# File 'lib/vote_smart/office.rb', line 91

def level_id
  @level_id
end

#nameObject

Returns the value of attribute name.



91
92
93
# File 'lib/vote_smart/office.rb', line 91

def name
  @name
end

Class Method Details

.allObject



96
97
98
# File 'lib/vote_smart/office.rb', line 96

def self.all
  @types ||= response_child(Office.get_types, "officeTypes", "type").collect {|attributes| Type.new(attributes)}
end

.find_by_name(name) ⇒ Object



100
101
102
# File 'lib/vote_smart/office.rb', line 100

def self.find_by_name name
  Type.all.collect {|type| type if type.name == name }.compact.first
end

Instance Method Details

#office_by_name(name) ⇒ Object



112
113
114
# File 'lib/vote_smart/office.rb', line 112

def office_by_name name
  offices_by_name([name]).first
end

#officesObject



104
105
106
# File 'lib/vote_smart/office.rb', line 104

def offices
  @offices ||= Office.find_all_by_type(self)
end

#offices_by_name(names) ⇒ Object



108
109
110
# File 'lib/vote_smart/office.rb', line 108

def offices_by_name names
  names.collect {|name| offices.find {|office| office.name == name }}
end