class DmtdVbmappData::GuideChapter
Provides for the retrieving of VB-MAPP Guide
chapters from the VB-MAPP Data Server.
Attributes
@!attribute [r] chapter_num
@return [Integer] the number of the chapter (0..n)
@!attribute [r] client
@return [Client] the associated client
@!attribute [r] chapter_title
@return [String] the title of the chapter
Public Class Methods
Creates an accessor for the VB-MAPP Guide
Chapter on the VB-MAPP Data Server
@note This method does not block, simply creates an accessor and returns
@option opts [Client] :client A client instance @option opts [Integer] :chapter_num The number (index 0..n) of the chapter in the Guide's index array @option opts [Hash] :chapter_index_json The guide index json for the chapter in the format described at
{https://datamtd.atlassian.net/wiki/pages/viewpage.action?pageId=18710558 1/guide/index REST api - Chapter Fields}
# File lib/dmtd_vbmapp_data/guide_chapter.rb, line 28 def initialize(opts) @client = opts.fetch(:client) @chapter_num = opts.fetch(:chapter_num).to_i index_json = opts.fetch(:chapter_index_json) @title = index_json[:title] @sections_index = index_json[:sections] end
Private Class Methods
# File lib/dmtd_vbmapp_data/guide_chapter.rb, line 60 def self.end_point '1/guide/chapter' end
Public Instance Methods
@note This method does block as the content is retrieved
@return [String] The preamble of the Guide's chapter
# File lib/dmtd_vbmapp_data/guide_chapter.rb, line 41 def content @content = retrieve_guide_chapter[:content] if @content.nil? @content end
@note This method does not block
@return [Array<GuideChapterSection>] all of the the VB-MAPP Guide's {GuideChapterSection} instances
# File lib/dmtd_vbmapp_data/guide_chapter.rb, line 50 def sections @sections = @sections_index.map.with_index do |section_index_json, section_num| GuideChapterSection.new(client: client, chapter_num: chapter_num, section_num: section_num, section_index_json: section_index_json) end if @sections.nil? @sections end
Private Instance Methods
# File lib/dmtd_vbmapp_data/guide_chapter.rb, line 64 def retrieve_guide_chapter params = { chapter_num: chapter_num } response = RequestHelpers::get_authorized(end_point: GuideChapter::end_point, params: params, client_id: @client.id, client_code: @client.code, language:client.language) proc_response = RequestHelpers::process_json_response(response) json = proc_response[:json] server_response_code = proc_response[:code] result = json result = server_response_code if json.nil? result end