Class: Snafu::Models::Hub
Overview
Defines a class for Glitch Hubs, which are the various regions in the game.
Instance Attribute Summary (collapse)
-
- (Object) id
readonly
Returns the value of attribute id.
-
- (Object) streets
readonly
Returns the value of attribute streets.
Attributes inherited from Location
Instance Method Summary (collapse)
-
- (Hub) initialize(options = {})
constructor
Accepts either the raw JSON-formatted response from the HTTParty get request or an options hash.
- - (Object) to_s
Methods inherited from Location
Constructor Details
- (Hub) initialize(options = {})
Accepts either the raw JSON-formatted response from the HTTParty get request or an options hash.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/snafu/models/hub.rb', line 11 def initialize( = {}) if .class == HTTParty::Response # construct the street information @id = ["hub_id"] @name = ["name"] @streets = [] ["streets"].each do |street_id, street| @streets << Street.new(:id => street_id, :name => street["name"]) end else @id = [:id] @name = [:name] if [:streets].is_a? Array @streets = [:streets] else @streets = [[:streets]] end end end |
Instance Attribute Details
- (Object) id (readonly)
Returns the value of attribute id
6 7 8 |
# File 'lib/snafu/models/hub.rb', line 6 def id @id end |
- (Object) streets (readonly)
Returns the value of attribute streets
6 7 8 |
# File 'lib/snafu/models/hub.rb', line 6 def streets @streets end |
Instance Method Details
- (Object) to_s
30 31 32 |
# File 'lib/snafu/models/hub.rb', line 30 def to_s "Glitch Hub - ID: #{self.id} Name: #{self.name}" end |