class GTFS::ORM::Resource

Public Class Methods

all() click to toggle source
# File lib/gtfs/orm/resource.rb, line 31
def self.all
  Scope.new(collection).all
end
first() click to toggle source
# File lib/gtfs/orm/resource.rb, line 19
def self.first
  Scope.new(collection).first
end
last() click to toggle source
# File lib/gtfs/orm/resource.rb, line 23
def self.last
  Scope.new(collection).last
end
limit(max) click to toggle source
# File lib/gtfs/orm/resource.rb, line 27
def self.limit(max)
  Scope.new(collection).limit(max)
end
page(page) click to toggle source

CLASS METHODS

# File lib/gtfs/orm/resource.rb, line 15
def self.page(page)
  Scope.new(page)
end
where(conditions) click to toggle source
# File lib/gtfs/orm/resource.rb, line 35
def self.where(conditions)
  Scope.new(collection).where(conditions)
end

Private Class Methods

base_path() click to toggle source
# File lib/gtfs/orm/resource.rb, line 41
def self.base_path
  ORM.path
end
collection() click to toggle source
# File lib/gtfs/orm/resource.rb, line 49
def self.collection
  unless @collection
    raise NonExistentResourceError unless File.exist?(file_path)
    @collection = []
    CSV.read(file_path, headers: true).map do |row|
      @collection << new( Hash[row.headers.zip(row.fields)] )
    end
  end
  @collection
end
file_path() click to toggle source
# File lib/gtfs/orm/resource.rb, line 45
def self.file_path
  File.join(base_path, self::FILE_NAME)
end