Class: Fushin::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/fushin/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, link:) ⇒ Item

Returns a new instance of Item.



7
8
9
10
# File 'lib/fushin/item.rb', line 7

def initialize(title:, link:)
  @title = title
  @link = link
end

Instance Attribute Details

Returns the value of attribute link.



5
6
7
# File 'lib/fushin/item.rb', line 5

def link
  @link
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/fushin/item.rb', line 5

def title
  @title
end

Instance Method Details

#postObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fushin/item.rb', line 12

def post
  @post ||= [].tap do |out|
    case link
    when /jugem\.jp/
      out << Posts::Jugem.new(link)
    when /kikey\.net/
      out << Posts::Kikey.new(link)
    when /seesaa\.net/
      out << Posts::Seesaa.new(link)
    when /shinobi\.jp/
      out << Posts::Shinobi.new(link)
    when /teacup\.com/
      out << Posts::Teacup.new(link)
    when /sblo\.jp/
      out << Posts::Sblo.new(link)
    else
      raise NoMachingPostsError
    end
  end.first
end