Sha256: d66030e71f35fe81e01aac8efbb688a98617196fb7adf24158aabce48507b9eb

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

module Kanpachi
  # Class to keep track of all defined sections
  #
  # @api public
  class SectionList
    def initialize
      @list = {}
    end

    # Returns a hash of sections
    #
    # @return [Hash<Kanpachi::Section>] All the added sections.
    # @api public
    def to_hash
      @list
    end

    # Returns an array of sections
    #
    # @return [Array<Kanpachi::Section>] List of added sections.
    # @api public
    def all
      @list.values
    end

    # Add a section to the list
    #
    # @param [Kanpachi::Section] section The section to add.
    # @return [Hash<Kanpachi::Section>] All the added sections.
    # @api public
    def add(section)
      @list[section.name] = section
    end

    # Returns a section based on its verb and url
    #
    # @param [String] verb The request method (GET, POST, PUT, DELETE)
    # @param [String] url The url of the section you are looking for.
    # @return [Nil, Kanpachi::Section] The found section.
    #
    # @api public
    def find(name)
      @list[name]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kanpachi-0.0.7 lib/kanpachi/section_list.rb
kanpachi-0.0.6 lib/kanpachi/section_list.rb
kanpachi-0.0.5 lib/kanpachi/section_list.rb
kanpachi-0.0.4 lib/kanpachi/section_list.rb
kanpachi-0.0.3 lib/kanpachi/section_list.rb
kanpachi-0.0.2 lib/kanpachi/section_list.rb
kanpachi-0.0.1 lib/kanpachi/section_list.rb