class TokyoMetro::Api::Fare::Info

2駅間の運賃を扱うクラス

Attributes

dc_date[R]

データ生成日時(ISO8601 日付時刻形式) @return [String]

from[R]

駅間の始点駅 @return [String]

from_sta[R]

駅間の始点駅 @return [String]

from_station[R]

駅間の始点駅 @return [String]

normal_fare[R]

運賃の情報を扱うインスタンス @return [::TokyoMetro::Static::Fare::Normal::Pattern]

operator[R]

運行会社 @return [String]

same_as[R]

固有識別子 @return [String] @note 命名ルールは「odpt.RailwayFare:TokyoMetro.出発駅の路線名.出発駅名.TokyoMetro.到着駅の路線名.到着駅名」

to[R]

駅間の終点駅 @return [String]

to_sta[R]

駅間の終点駅 @return [String]

to_station[R]

駅間の終点駅 @return [String]

Public Class Methods

attr_names() click to toggle source
# File lib/tokyo_metro/api/fare/info.rb, line 19
def self.attr_names
  [ :id_urn , :same_as , :dc_date , :operator , :from_station , :to_station , :normal_fare ]
end
new( id_urn , same_as , dc_date , operator , from_station , to_station , normal_fare ) click to toggle source

Constructor

# File lib/tokyo_metro/api/fare/info.rb, line 9
def initialize( id_urn , same_as , dc_date , operator , from_station , to_station , normal_fare )
  @id_urn = id_urn
  @same_as = same_as
  @dc_date = dc_date
  @operator = operator
  @from_station = from_station
  @to_station = to_station
  @normal_fare = normal_fare
end

Public Instance Methods

child_coupon_ticket_fare() click to toggle source

回数券(小児)の発売額 @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 158
def child_coupon_ticket_fare
  @normal_fare.child_coupon_ticket_fare
end
child_daytime_coupon_ticket_per_one_piece() click to toggle source

時差回数券(小児・12枚つづり)の1枚あたりの発売額 @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 188
def child_daytime_coupon_ticket_per_one_piece
  @normal_fare.child_daytime_coupon_ticket_per_one_piece
end
child_holiday_coupon_ticket_per_one_piece() click to toggle source

土休回数券(小児・14枚つづり)の1枚あたりの発売額 @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 194
def child_holiday_coupon_ticket_per_one_piece
  @normal_fare.child_holiday_coupon_ticket_per_one_piece
end
child_ic_card_fare() click to toggle source

普通運賃(小児・ICカード) @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 144
def child_ic_card_fare
  @normal_fare.child_ic_card_fare
end
child_normal_coupon_ticket_per_one_piece() click to toggle source

普通回数券(小児・11枚つづり)の1枚あたりの発売額 @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 182
def child_normal_coupon_ticket_per_one_piece
  @normal_fare.child_normal_coupon_ticket_per_one_piece
end
child_ticket_fare() click to toggle source

普通運賃(小児・切符) @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 132
def child_ticket_fare
  @normal_fare.child_ticket_fare
end
coupon_ticket_fare() click to toggle source

回数券(大人)の発売額 @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 152
def coupon_ticket_fare
  @normal_fare.coupon_ticket_fare
end
daytime_coupon_ticket_per_one_piece() click to toggle source

時差回数券(大人・12枚つづり)の1枚あたりの発売額 @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 170
def daytime_coupon_ticket_per_one_piece
  @normal_fare.daytime_coupon_ticket_per_one_piece
end
from?( *stations ) click to toggle source

@param stations [String, Regexp , Array<String or Regexp>]

# File lib/tokyo_metro/api/fare/info.rb, line 49
def from?( *stations )
  stations.flatten.any? { | station | station === @from_station }
end
Also aliased as: is_from?
from_or_to?( *stations ) click to toggle source
# File lib/tokyo_metro/api/fare/info.rb, line 58
def from_or_to?( *stations )
  from?( *stations ) or to?( *stations )
end
Also aliased as: is_from_or_to?
holiday_coupon_ticket_per_one_piece() click to toggle source

土休回数券(大人・14枚つづり)の1枚あたりの発売額 @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 176
def holiday_coupon_ticket_per_one_piece
  @normal_fare.holiday_coupon_ticket_per_one_piece
end
ic_card_fare() click to toggle source

普通運賃(大人・ICカード) @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 138
def ic_card_fare
  @normal_fare.ic_card_fare
end
is_from?( *stations )
Alias for: from?
is_from_or_to?( *stations )
Alias for: from_or_to?
is_to?( *stations )
Alias for: to?
normal_coupon_ticket_per_one_piece() click to toggle source

普通回数券(大人・11枚つづり)の1枚あたりの発売額 @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 164
def normal_coupon_ticket_per_one_piece
  @normal_fare.normal_coupon_ticket_per_one_piece
end
ticket_fare() click to toggle source

普通運賃(大人・切符) @return [Integer]

# File lib/tokyo_metro/api/fare/info.rb, line 126
def ticket_fare
  @normal_fare.ticket_fare
end
to?( *stations ) click to toggle source

@param stations [String, Regexp , Array<String or Regexp>]

# File lib/tokyo_metro/api/fare/info.rb, line 54
def to?( *stations )
  stations.flatten.any? { | station | station === @to_station }
end
Also aliased as: is_to?
to_h() click to toggle source

インスタンスの情報をハッシュにして返すメソッド @return [Hash]

# File lib/tokyo_metro/api/fare/info.rb, line 76
def to_h
  h = Hash.new

  set_data_to_hash( h , "\@id" , @id_urn )
  set_data_to_hash( h , "owl:sameAs" , @same_as )
  set_data_to_hash( h , "dc:date" , @dc_date.to_s )
  set_data_to_hash( h , "odpt:operator" , @operator )
  set_data_to_hash( h , "odpt:fromStation" , @from_station )
  set_data_to_hash( h , "odpt:toStation" , @to_station )

  set_data_to_hash( h , "odpt:ticketFare" , self.ticket_fare )
  set_data_to_hash( h , "odpt:childTicketFare" , self.child_ticket_fare )
  set_data_to_hash( h , "odpt:icCardFare" , self.ic_card_fare )
  set_data_to_hash( h , "odpt:childIcCardFare" , self.child_ic_card_fare )

  h
end
to_s( indent = 0 ) click to toggle source

インスタンスの情報を文字列にして返すメソッド @param indent [Integer (>0)] インデントの幅 @return [String]

# File lib/tokyo_metro/api/fare/info.rb, line 97
def to_s ( indent = 0 )
  h = self.to_h
  hash_keys_ary_1 = [ "\@id" , "owl:sameAs" , "dc:date" ]
  hash_keys_ary_2 = [ "odpt:operator" , "odpt:fromStation" , "odpt:toStation" ]
  hash_keys_ary_3 = [ "odpt:ticketFare" , "odpt:childTicketFare" , "odpt:icCardFare" , "odpt:childIcCardFare" ]

  str_ary = ::Array.new
  str_ary << " " * indent + "#{@from_station} - #{@to_station}"
  str_ary << ""

  [ hash_keys_ary_1 , hash_keys_ary_2 ].each do | hash_keys_ary |
    hash_keys_ary.each do | key |
      if h[ key ].present?
        str_ary << ( " " * ( indent + 2 ) + key.ljust(32) + h[ key ].to_strf )
      end
    end
    str_ary << ""
  end

  str_ary << @normal_fare.to_s_table( indent + 2 )
  str_ary.join( "\n" )
end
Also aliased as: to_strf
to_strf( indent = 0 )
Alias for: to_s