Class: Article

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(link) ⇒ Article

Returns a new instance of Article.



23
24
25
# File 'lib/link2epub.rb', line 23

def initialize(link)
    @link = link
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



21
22
23
# File 'lib/link2epub.rb', line 21

def author
  @author
end

#contentObject

Returns the value of attribute content.



21
22
23
# File 'lib/link2epub.rb', line 21

def content
  @content
end

#dateObject

Returns the value of attribute date.



21
22
23
# File 'lib/link2epub.rb', line 21

def date
  @date
end

#fileObject

Returns the value of attribute file.



21
22
23
# File 'lib/link2epub.rb', line 21

def file
  @file
end

Returns the value of attribute link.



21
22
23
# File 'lib/link2epub.rb', line 21

def link
  @link
end

#titleObject

Returns the value of attribute title.



21
22
23
# File 'lib/link2epub.rb', line 21

def title
  @title
end

#tplObject

Returns the value of attribute tpl.



21
22
23
# File 'lib/link2epub.rb', line 21

def tpl
  @tpl
end

Instance Method Details

#to_fileObject



27
28
29
30
31
32
33
34
# File 'lib/link2epub.rb', line 27

def to_file
    tpl = File.read(@tpl)
    eruby = Erubis::Eruby.new(tpl)

    File.open(@file, 'w') do |f|
        f.puts eruby.evaluate(self)
    end
end

#to_sObject



36
37
38
39
40
41
# File 'lib/link2epub.rb', line 36

def to_s
    puts "link: #{@link}"
    puts "title: #{@title}"
    puts "author: #{@author}"
    # puts "content: #{@content}"
end