Class: GtfsReader::Config::FeedDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/gtfs_reader/config/feed_definition.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initializeFeedDefinition

Returns a new instance of FeedDefinition.



8
9
10
# File 'lib/gtfs_reader/config/feed_definition.rb', line 8

def initialize
  @file_definition = {}
end

Instance Method Details

#file(name, *args, &block) ⇒ FileDefinition #file(name) ⇒ FileDefinition

Overloads:

  • #file(name, *args, &block) ⇒ FileDefinition

    Defines a new file in the feed.

    Parameters:

    • name (String)

      the name of this file within the feed. This name should not include a file extension (like .txt)

    • args (Array)

      the first argument is used as a Hash of options to create the new file definition

    • block (Proc)

      this block is instance_evaled on the new file

    Returns:

  • #file(name) ⇒ FileDefinition

    Returns the previously created file with name.

    Parameters:

    • name (String)

      the name of the file to return

    Returns:

See Also:



40
41
42
43
44
45
46
# 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

#filesArray<FileDefinition>

Returns All of the defined files.

Returns:



13
14
15
# File 'lib/gtfs_reader/config/feed_definition.rb', line 13

def files
  @file_definition.values
end

#optional_filesObject



21
22
23
# File 'lib/gtfs_reader/config/feed_definition.rb', line 21

def optional_files
  files.reject(&:required?)
end

#required_filesObject



17
18
19
# File 'lib/gtfs_reader/config/feed_definition.rb', line 17

def required_files
  files.select(&:required?)
end