Class: TokyoMetro::Static::Fare::Normal::Table::List

Inherits:
Array
  • Object
show all
Includes:
ClassNameLibrary::Static::Fare, Modules::Common::ToFactory::Seed::List
Defined in:
lib/tokyo_metro/static/fare/normal/table/list.rb

Overview

各料金区間の運賃の配列

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Modules::Common::ToFactory::Seed::Group

#seed

Class Method Details

.factory_for_seeding_this_classObject



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

運賃の情報を出力する際のヘッダー

Parameters:

  • indent (Integer (>0) (defaults to: 0)

    ] インデントの幅

Returns:

  • (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) から該当する要素を抜き出して返すメソッド

Parameters:

  • ticket_fare (Integer)

    普通運賃(大人・切符)

  • child_ticket_fare (Integer)

    普通運賃(小児・切符)

  • ic_card_fare (Integer)

    普通運賃(大人・ICカード)

  • child_ic_card_fare (Integer)

    普通運賃(小児・ICカード)

Returns:



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

運賃の配列を文字列として返すメソッド

Parameters:

  • indent (Integer (>0) (defaults to: 0)

    ] インデントの幅

Returns:

  • (String)


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