class GtfsReader::Config::FeedDefinition

Describes a GTFS feed and the {FileDefinition files} it is expected to provide.

Public Class Methods

new() click to toggle source
# File lib/gtfs_reader/config/feed_definition.rb, line 8
def initialize
  @file_definition = {}
end

Public Instance Methods

file(name, *args, &block) click to toggle source

@overload file(name, *args, &block)

Defines a new file in the feed.

@param name [String] the name of this file within the feed. This name
  should not include a file extension (like +.txt+)
@param args [Array] the first argument is used as a +Hash+ of options
  to create the new file definition
@param block [Proc] this block is +instance_eval+ed on the new
  {FileDefinition file}
@return [FileDefinition] the newly created file

@overload file(name)

@param name [String] the name of the file to return
@return [FileDefinition] the previously created file with +name+

@see FileDefinition

# File lib/gtfs_reader/config/feed_definition.rb, line 40
def file(name, *args, &block)
  return @file_definition[name] unless block_given?

  definition_for!(name, args.first).tap do |definition|
    definition.instance_exec(&block) if block
  end
end
files() click to toggle source

@return [Array<FileDefinition>] All of the defined files.

# File lib/gtfs_reader/config/feed_definition.rb, line 13
def files
  @file_definition.values
end
optional_files() click to toggle source
# File lib/gtfs_reader/config/feed_definition.rb, line 21
def optional_files
  files.reject(&:required?)
end
required_files() click to toggle source
# File lib/gtfs_reader/config/feed_definition.rb, line 17
def required_files
  files.select(&:required?)
end

Private Instance Methods

definition_for!(name, opts) click to toggle source
# File lib/gtfs_reader/config/feed_definition.rb, line 50
def definition_for!(name, opts)
  @file_definition[name] ||= FileDefinition.new(name, opts)
end