Module: ButterSand::API::Events
- Included in:
- Client
- Defined in:
- lib/butter_sand/api/events.rb
Constant Summary collapse
- PATH_SAIJI =
'/contents/shop/saiji/'
Instance Method Summary collapse
-
#all ⇒ Array<ButterSand::Event>
Returns list of all event information listed on the page.
-
#ends_today ⇒ Array<ButterSand::Event>
Returns list of event information that ends today.
-
#find_by_prefecture(name) ⇒ Array<ButterSand::Event>
Returns list of event information selected with given prefecture name.
-
#on_sale ⇒ Array<ButterSand::Event>
Returns list of event information being held.
-
#starts_today ⇒ Array<ButterSand::Event>
Returns list of event information that starts today.
Instance Method Details
#all ⇒ Array<ButterSand::Event>
Returns list of all event information listed on the page. When there is no event information to be held, returns empty array.
13 14 15 |
# File 'lib/butter_sand/api/events.rb', line 13 def all ButterSand::Parser.to_array(get(PATH_SAIJI)).map {|event| ButterSand::Event.new(event)} end |
#ends_today ⇒ Array<ButterSand::Event>
Returns list of event information that ends today. When there is no corresponding data, returns empty array.
34 35 36 |
# File 'lib/butter_sand/api/events.rb', line 34 def ends_today all.select {|event| event.ends == (@date_for_test || Date.today)} end |
#find_by_prefecture(name) ⇒ Array<ButterSand::Event>
Returns list of event information selected with given prefecture name. When there is no corresponding data, returns empty array.
43 44 45 46 |
# File 'lib/butter_sand/api/events.rb', line 43 def find_by_prefecture(name) raise ArgumentError , 'Illegal argument' unless name.kind_of? String all.select {|event| event.prefecture == name} end |
#on_sale ⇒ Array<ButterSand::Event>
Returns list of event information being held. When there is no corresponding data, returns empty array.
20 21 22 |
# File 'lib/butter_sand/api/events.rb', line 20 def on_sale all.select {|event| (event.starts..event.ends) === (@date_for_test || Date.today)} end |
#starts_today ⇒ Array<ButterSand::Event>
Returns list of event information that starts today. When there is no corresponding data, returns empty array.
27 28 29 |
# File 'lib/butter_sand/api/events.rb', line 27 def starts_today all.select {|event| event.starts == (@date_for_test || Date.today)} end |