class TokyoMetro::Static::TrainType::Color::Info

個別の種別の色を扱うクラス

Attributes

note[R]

@return [String] 種別色の補足情報(インスタンス変数) @example

TokyoMetro::Static.train_types_color.each_value { | color | puts color.note }
=>
一般 標準色 白
一般 標準色 グレー
土休急行 標準色(ピンク)
same_as[R]

@return [String] 種別色の ID(インスタンス変数) @example

TokyoMetro::Static.train_types_color.each_value { | color | puts color.same_as }
=>
custom.TrainTypeColor:White
custom.TrainTypeColor:DarkGray
custom.TrainTypeColor:HolidayExpress

Public Class Methods

new( same_as , note , *wrgb ) click to toggle source

Constructor @param same_as [String] 作成するインスタンスの ID キー @param note [String] 作成するインスタンスの補足情報 @param wrgb [::Array] 作成するインスタンスの WebColor と RGB の各成分の情報

Calls superclass method TokyoMetro::Static::Color::new
# File lib/tokyo_metro/static/train_type/color/info.rb, line 13
def initialize( same_as , note , *wrgb )
  @same_as = same_as
  @note = note
  super( *wrgb )
end

Public Instance Methods

<=>( other ) click to toggle source

インスタンスの比較に用いるメソッド @return [Integer]

# File lib/tokyo_metro/static/train_type/color/info.rb, line 69
def <=>( other )
  @same_as <=> other.same_as
end
to_rgb_color_in_parentheses() click to toggle source

Red, Green, Blue の各成分の情報を括弧で囲んだ文字列にして返すメソッド @return [String] @example

TokyoMetro::Static.train_types_color.each_value { | color | puts color.same_as.ljust(48) + " " + color.to_rgb_color_in_parentheses }
=>
custom.TrainTypeColor:White                      ( 255 , 255 , 255 )
custom.TrainTypeColor:DarkGray                   ( 102 , 102 , 102 )
custom.TrainTypeColor:HolidayExpress             ( 255 , 51 , 153 )
Calls superclass method
# File lib/tokyo_metro/static/train_type/color/info.rb, line 61
def to_rgb_color_in_parentheses
  super
end
to_s( indent = 0 ) click to toggle source

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

Calls superclass method TokyoMetro::Static::Color#to_s
# File lib/tokyo_metro/static/train_type/color/info.rb, line 76
def to_s( indent = 0 )
  if @same_as.nil?
    same_as = "----"
  else
    same_as = @same_as.to_s
  end
  [ same_as , @note.to_s ].map { | str |" " * indent + str }.join( "\n" ) + "\n" + " " * ( indent + 2 ) + super(0)
end
web() click to toggle source

WebColor を取得するメソッド @return [String] @example

TokyoMetro::Static.train_types_color.each_value { | color | puts color.same_as.ljust(48) + " " + color.web }
=>
custom.TrainTypeColor:White                      #ffffff
custom.TrainTypeColor:DarkGray                   #666666
custom.TrainTypeColor:HolidayExpress             #ff3399
Calls superclass method
# File lib/tokyo_metro/static/train_type/color/info.rb, line 49
def web
  super
end