class ButterCMS::Parsers::Posts

Attributes

response[R]

Public Class Methods

new(response) click to toggle source
# File lib/butter_cms/parsers/posts.rb, line 7
def initialize(response)
  @response = response
end

Public Instance Methods

count() click to toggle source

Returns the count of existing posts

@return [String]

# File lib/butter_cms/parsers/posts.rb, line 28
def count
  parsed_json['meta']['count']
end
next_page() click to toggle source

Returns the number of the next page or nil if not available

@return [String]

# File lib/butter_cms/parsers/posts.rb, line 14
def next_page
  parsed_json['meta']['next_page']
end
posts() click to toggle source

Returns array of posts attributes available in the response

@return [Array]

# File lib/butter_cms/parsers/posts.rb, line 35
def posts
  parsed_json['data']
end
previous_page() click to toggle source

Returns the number of the previous page or nil if not available

@return [String]

# File lib/butter_cms/parsers/posts.rb, line 21
def previous_page
  parsed_json['meta']['previous_page']
end

Private Instance Methods

parsed_json() click to toggle source
# File lib/butter_cms/parsers/posts.rb, line 43
def parsed_json
  @parsed_json ||= ::JSON.parse(response.body)
end