Class: TokyoMetro::Api::MetaClass::RealTime::List

Inherits:
Fundamental::List show all
Includes:
Modules::Api::Common::RealTime
Defined in:
lib/tokyo_metro/api/meta_class/real_time/list.rb

Overview

「データ検索 API を利用するリアルタイム情報」の配列(メタクラス)

Direct Known Subclasses

TrainLocation::List, TrainOperation::List

Instance Method Summary collapse

Methods inherited from Fundamental::List

#find_by_same_as, #to_strf

Instance Method Details

#update!(*args, time: ::TokyoMetro.time_now) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/tokyo_metro/api/meta_class/real_time/list.rb', line 10

def update!( *args , time: ::TokyoMetro.time_now )
  unless valid?( time )
    self.delete!( &:present? )
    new_infos = self.class.toplevel_namespace.get( *args , parse_json: true , generate_instance: true )
    new_infos.each do | info |
      self.push( info )
    end
  end
  return self
end

#valid?(time = ::TokyoMetro.time_now) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/tokyo_metro/api/meta_class/real_time/list.rb', line 6

def valid?( time = ::TokyoMetro.time_now )
  self.all? { | info | info.valid?( time ) }
end