Module: Blogtext
- Defined in:
- lib/blogtext.rb,
lib/blogtext/io.rb,
lib/blogtext/link.rb,
lib/blogtext/audio.rb,
lib/blogtext/image.rb,
lib/blogtext/quote.rb,
lib/blogtext/video.rb,
lib/blogtext/version.rb,
lib/blogtext/paragraph.rb
Defined Under Namespace
Modules: Audio, IO, Image, Link, Paragraph, Quote, Video
Constant Summary
collapse
- VERSION =
"1.0.0"
Class Method Summary
collapse
Class Method Details
.cli_convert ⇒ Object
34
35
36
37
38
39
|
# File 'lib/blogtext.rb', line 34
def self.cli_convert
@filename = ARGV[0]
puts @filename
@changes = convert @filename
IO.write(@filename,@changes)
end
|
.convert(filename) ⇒ Object
29
30
31
32
|
# File 'lib/blogtext.rb', line 29
def self.convert filename
@contents = IO.read(filename)
perform
end
|
.new_contents(arr) ⇒ Object
12
13
14
|
# File 'lib/blogtext.rb', line 12
def self.new_contents(arr)
arr.join("\n")
end
|
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/blogtext.rb', line 16
def self.perform
res = []
@contents.each_with_index do |l,i|
res.push("<h1>#{l.strip}</h1>") if (i == 0)
res.push("<h3>#{l.strip}</h3>") if (i == 1)
res.push(Video.add(l)) if l.start_with?("[video]")
res.push(Image.add(l)) if l.start_with?("[image]")
res.push(Quote.add(l)) if l.start_with?("[quote]")
res.push(Paragraph.add(l.strip)) if ((i>1) && !l.start_with?("[quote]","[image]","[video]"))
end
@newcontents = new_contents(res)
end
|
.version_info ⇒ Object
4
5
6
7
|
# File 'lib/blogtext/version.rb', line 4
def self.version_info
puts "Blogtext gem - Version #{VERSION}"
puts "Author: Ed de Almeida (evaldoajunior@gmail.com)"
end
|