Class: MediumToWebflow::Medium::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/medium_to_webflow/medium/post.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Post

Returns a new instance of Post.



10
11
12
13
14
15
16
17
18
# File 'lib/medium_to_webflow/medium/post.rb', line 10

def initialize(attributes)
  @title = attributes[:title]
  @url = attributes[:url]
  @published_at = attributes[:published_at]
  @author = attributes[:author]
  @image_url = attributes[:image_url]
  @category = attributes[:category]
  @guid = attributes[:guid]
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



8
9
10
# File 'lib/medium_to_webflow/medium/post.rb', line 8

def author
  @author
end

#categoryObject (readonly)

Returns the value of attribute category.



8
9
10
# File 'lib/medium_to_webflow/medium/post.rb', line 8

def category
  @category
end

#guidObject (readonly)

Returns the value of attribute guid.



8
9
10
# File 'lib/medium_to_webflow/medium/post.rb', line 8

def guid
  @guid
end

#image_urlObject (readonly)

Returns the value of attribute image_url.



8
9
10
# File 'lib/medium_to_webflow/medium/post.rb', line 8

def image_url
  @image_url
end

#published_atObject (readonly)

Returns the value of attribute published_at.



8
9
10
# File 'lib/medium_to_webflow/medium/post.rb', line 8

def published_at
  @published_at
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'lib/medium_to_webflow/medium/post.rb', line 8

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/medium_to_webflow/medium/post.rb', line 8

def url
  @url
end

Class Method Details

.from_rss(item) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/medium_to_webflow/medium/post.rb', line 21

def from_rss(item)
  new(
    title: item.title,
    url: item.link,
    published_at: item.pubDate,
    author: item.author || item.dc_creator,
    image_url: extract_image_url(item.content_encoded, item.description),
    category: humanize_category(item.categories&.first&.content),
    guid: extract_guid(item.guid.content)
  )
end