Sha256: a44fa4667e67ac630a418c13e939728e46459deb5c0807b417d05ef82c09399e

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

module Jiralicious
  ##
  # The SearchResult class organizes the response from the Jira API
  # In a way that is easily parsable into Issues.
  #
  class SearchResult
    # Attributes available for usage regarding the current position in the list
    attr_reader :offset, :num_results

    ##
    # Initialization Method
    #
    # Parses the hash into attributes.
    #
    # [Arguments]
    # :search_data    (required)    hash data to be parsed
    #
    def initialize(search_data)
      @issues      = search_data["issues"]
      @offset      = search_data["startAt"]
      @num_results = search_data["total"]
    end

    ##
    # Loads the different issues through the map. This is not recommended
    # for large objects as it can be troublesome to load multiple Issues
    # to locate the desired one. If the user needs to have all of the
    # information available on each issue this method works perfectly for
    # that process.
    #
    def issues
      @issues.map do |issue|
        Jiralicious::Issue.find(issue["key"])
      end
    end

    ##
    # Returns the Issues attribute without loading the extra information.
    # Ideal for a quick scan of the Hash prior to selecting the correct
    # Issue. This method is also used in the lazy loading methodology.
    #
    def issues_raw
      @issues
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jiralicious-0.5.0 lib/jiralicious/search_result.rb
jiralicious-0.4.3 lib/jiralicious/search_result.rb
jiralicious-0.4.0 lib/jiralicious/search_result.rb