Class: Rockstar::Metro

Inherits:
Base
  • Object
show all
Defined in:
lib/rockstar/metro.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

connection, fetch_and_parse, get_instance

Constructor Details

#initialize(name, country) ⇒ Metro

Returns a new instance of Metro.

Raises:

  • (ArgumentError)


15
16
17
18
19
20
# File 'lib/rockstar/metro.rb', line 15

def initialize(name, country)
  raise ArgumentError, "Name is required" if name.blank?
  raise ArgumentError, "Country is required" if country.blank?
  @name = name
  @country = country
end

Instance Attribute Details

#countryObject

Returns the value of attribute country.



4
5
6
# File 'lib/rockstar/metro.rb', line 4

def country
  @country
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/rockstar/metro.rb', line 4

def name
  @name
end

Class Method Details

.new_from_xml(xml, doc) ⇒ Object



7
8
9
10
11
12
# File 'lib/rockstar/metro.rb', line 7

def new_from_xml(xml, doc)
  Metro.new(
    (xml).at(:name).inner_html, 
    (xml).at(:country).inner_html
  )
end