Class: IrisRails::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/lib/iris_rails.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr = {}) ⇒ Post

Returns a new instance of Post.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/generators/lib/iris_rails.rb', line 59

def initialize(attr = {})
  @main_title = attr["main_title"]
  @slug = attr["slug"]
  @created_at = attr["created_at"]
  @updated_at = attr["updated_at"]
  @banner_image = attr["banner_image"]
  @banner_text = attr["banner_text"]
  @secondary_title = attr["secondary_title"]
  @first_introduction = attr["first_introduction"]
  @internal_links = attr["internal_links"]
  @second_introduction = attr["second_introduction"]
  @call_to_action_content = attr["call_to_action_content"]
  @call_to_action_link = attr["call_to_action_link"]
  @call_to_action_link_description = attr["call_to_action_link_description"]
  @closure_text = attr["closure_text"]
  @published = attr["published"]
  @keyphrase = attr["keyphrase"]
  @meta_description = attr["meta_description"]
  @seo_title = attr["seo_title"]
  @publish_date = attr["publish_date"]
  @published_at = attr["published_at"]
  @score = attr["score"]
  @author_id = attr["author_id"]
  @author = attr["author"]
  @ordered_topics = attr["ordered_topics"]
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def author
  @author
end

#author_idObject

Returns the value of attribute author_id.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def author_id
  @author_id
end

Returns the value of attribute banner_image.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def banner_image
  @banner_image
end

Returns the value of attribute banner_text.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def banner_text
  @banner_text
end

#call_to_action_contentObject

Returns the value of attribute call_to_action_content.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def call_to_action_content
  @call_to_action_content
end

Returns the value of attribute call_to_action_link.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def call_to_action_link
  @call_to_action_link
end

Returns the value of attribute call_to_action_link_description.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def call_to_action_link_description
  @call_to_action_link_description
end

#closure_textObject

Returns the value of attribute closure_text.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def closure_text
  @closure_text
end

#created_atObject

Returns the value of attribute created_at.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def created_at
  @created_at
end

#first_introductionObject

Returns the value of attribute first_introduction.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def first_introduction
  @first_introduction
end

Returns the value of attribute internal_links.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def internal_links
  @internal_links
end

#keyphraseObject

Returns the value of attribute keyphrase.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def keyphrase
  @keyphrase
end

#main_titleObject

Returns the value of attribute main_title.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def main_title
  @main_title
end

#meta_descriptionObject

Returns the value of attribute meta_description.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def meta_description
  @meta_description
end

#ordered_topicsObject

Returns the value of attribute ordered_topics.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def ordered_topics
  @ordered_topics
end

#publish_dateObject

Returns the value of attribute publish_date.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def publish_date
  @publish_date
end

#publishedObject

Returns the value of attribute published.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def published
  @published
end

#published_atObject

Returns the value of attribute published_at.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def published_at
  @published_at
end

#scoreObject

Returns the value of attribute score.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def score
  @score
end

#second_introductionObject

Returns the value of attribute second_introduction.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def second_introduction
  @second_introduction
end

#secondary_titleObject

Returns the value of attribute secondary_title.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def secondary_title
  @secondary_title
end

#seo_titleObject

Returns the value of attribute seo_title.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def seo_title
  @seo_title
end

#slugObject

Returns the value of attribute slug.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def slug
  @slug
end

#updated_atObject

Returns the value of attribute updated_at.



52
53
54
# File 'lib/generators/lib/iris_rails.rb', line 52

def updated_at
  @updated_at
end

Class Method Details

.allObject



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/generators/lib/iris_rails.rb', line 104

def self.all
  url = IrisRails.indexUrl
  response = RestClient.get(url, @headers)
  response = JSON.parse(response.body)
  puts response
  posts = []
  response['data'].each do |post|
    posts << self.new(post)
  end
   = IrisRails::Account.new(
    {account_name: response['account_name'],
    template: response['template'],
    account_title: response['account_title'],
    account_description: response['account_description'],
    account_keyword: response['account_keyword']}
  )
  return posts, 
end

.find(slug) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/generators/lib/iris_rails.rb', line 86

def self.find(slug)
  url = IrisRails.postUrl(slug)
  response = RestClient.get(url, @headers)
  response = JSON.parse(response.body)
  puts 'data'
  post = self.new(response['data'])
  related_posts = []
  response['related_posts'].each do |related_post|
    related_posts << self.new(related_post)
  end
  post.author = response['data']['author']
   = IrisRails::Account.new(
    {account_name: response['account_name'],
    template: response['template']}
  )
  return post, related_posts, 
end