Class: Zueribad::Bath
- Inherits:
-
Object
- Object
- Zueribad::Bath
- Defined in:
- lib/zueribad/bath.rb
Constant Summary collapse
- SERVICE_URL =
'https://www.stadt-zuerich.ch/stzh/bathdatadownload'
Instance Attribute Summary collapse
-
#modified_at ⇒ Object
Returns the value of attribute modified_at.
-
#name ⇒ Object
Returns the value of attribute name.
-
#open_status ⇒ Object
Returns the value of attribute open_status.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Bath
constructor
A new instance of Bath.
Constructor Details
#initialize(params = {}) ⇒ Bath
Returns a new instance of Bath.
18 19 20 21 22 23 24 |
# File 'lib/zueribad/bath.rb', line 18 def initialize(params = {}) params.each do |k,v| if respond_to? k instance_variable_set("@#{k}".to_sym, v) end end end |
Instance Attribute Details
#modified_at ⇒ Object
Returns the value of attribute modified_at.
16 17 18 |
# File 'lib/zueribad/bath.rb', line 16 def modified_at @modified_at end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/zueribad/bath.rb', line 13 def name @name end |
#open_status ⇒ Object
Returns the value of attribute open_status.
15 16 17 |
# File 'lib/zueribad/bath.rb', line 15 def open_status @open_status end |
#temperature ⇒ Object
Returns the value of attribute temperature.
14 15 16 |
# File 'lib/zueribad/bath.rb', line 14 def temperature @temperature end |
Class Method Details
.download ⇒ Object
43 44 45 |
# File 'lib/zueribad/bath.rb', line 43 def self.download open(SERVICE_URL).read end |
.fetch(name = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zueribad/bath.rb', line 26 def self.fetch(name = nil) doc = Nokogiri::Slop(self.download) baths = doc.bathinfos.baths.bath.map do |x| Bath.new(:name => x.title.content, :temperature => x.temperatureWater.content, :open_status => x.openClosedTextPlain.content, :modified_at => x.dateModified.content) end if name baths.select {|x| x.name =~ /#{name}/i} else baths end end |