Class: TokyoMetro::Static::Fare::Normal::Table::List
- Inherits:
-
Array
- Object
- Array
- TokyoMetro::Static::Fare::Normal::Table::List
- Defined in:
- lib/tokyo_metro/static/fare/normal/table/list.rb
Overview
各料金区間の運賃の配列
Class Method Summary collapse
- .factory_for_seeding_this_class ⇒ Object
-
.header(indent = 0) ⇒ String
運賃の情報を出力する際のヘッダー.
Instance Method Summary collapse
-
#select_fare(ticket_fare, child_ticket_fare, ic_card_fare, child_ic_card_fare) ⇒ Pattern
運賃情報の整数の列が与えられたときに、配列 (self) から該当する要素を抜き出して返すメソッド.
-
#to_s(indent = 0) ⇒ String
(also: #to_strf)
運賃の配列を文字列として返すメソッド.
Methods included from Modules::Common::ToFactory::Seed::Group
Class Method Details
.factory_for_seeding_this_class ⇒ Object
42 43 44 |
# File 'lib/tokyo_metro/static/fare/normal/table/list.rb', line 42 def self.factory_for_seeding_this_class factory_for_seeding_normal_table_list end |
.header(indent = 0) ⇒ String
運賃の情報を出力する際のヘッダー
38 39 40 |
# File 'lib/tokyo_metro/static/fare/normal/table/list.rb', line 38 def self.header( indent = 0 ) [ "Ticket" , "Ticket (Child)" , "IC Card" , "IC Card (Child)" ].map{ | i | i.ljust(16) }.join( " " * 8 ) end |
Instance Method Details
#select_fare(ticket_fare, child_ticket_fare, ic_card_fare, child_ic_card_fare) ⇒ Pattern
運賃情報の整数の列が与えられたときに、配列 (self) から該当する要素を抜き出して返すメソッド
26 27 28 29 30 31 32 33 |
# File 'lib/tokyo_metro/static/fare/normal/table/list.rb', line 26 def select_fare( ticket_fare , child_ticket_fare , ic_card_fare , child_ic_card_fare ) self.each do |i| if i.match?( ticket_fare , child_ticket_fare , ic_card_fare , child_ic_card_fare ) return i end end nil end |
#to_s(indent = 0) ⇒ String Also known as: to_strf
運賃の配列を文字列として返すメソッド
10 11 12 13 14 15 16 17 |
# File 'lib/tokyo_metro/static/fare/normal/table/list.rb', line 10 def to_s( indent = 0 ) str_ary = ::Array.new str_ary << self.class.header( indent ) self.each do | fare | str_ary << fare.to_s_in_a_row( indent ) end str_ary.join( "\n" ) end |