Class: KanazawaLoopBus::Bus
- Inherits:
-
Object
- Object
- KanazawaLoopBus::Bus
- Defined in:
- lib/kanazawa_loop_bus/bus.rb
Constant Summary collapse
- NAMES =
[ "鏡花号", "鏡花号", "秋声号", "犀星号" ]
Instance Attribute Summary collapse
-
#next_stop ⇒ Object
readonly
Returns the value of attribute next_stop.
-
#previous_stop ⇒ Object
readonly
Returns the value of attribute previous_stop.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(option) ⇒ Bus
constructor
A new instance of Bus.
- #name ⇒ Object
Constructor Details
Instance Attribute Details
#next_stop ⇒ Object (readonly)
Returns the value of attribute next_stop.
5 6 7 |
# File 'lib/kanazawa_loop_bus/bus.rb', line 5 def next_stop @next_stop end |
#previous_stop ⇒ Object (readonly)
Returns the value of attribute previous_stop.
5 6 7 |
# File 'lib/kanazawa_loop_bus/bus.rb', line 5 def previous_stop @previous_stop end |
Class Method Details
.from_node(node) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/kanazawa_loop_bus/bus.rb', line 15 def from_node(node) node = node.parent.parent id = /\.\.\/img\/busicon\/car_s_(\d)\.gif/.match(node["src"]).to_a[1].to_i or raise "Bus not found" Bus.new({ id: id-1, previous_stop_name: node.previous.css('font').inner_text, next_stop_name: node.next.css('font').inner_text }) end |
Instance Method Details
#name ⇒ Object
32 33 34 |
# File 'lib/kanazawa_loop_bus/bus.rb', line 32 def name NAMES[@id] end |