Class: OPML2HTML::Renderer

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

Instance Method Summary collapse

Constructor Details

#initialize(document, css:) ⇒ Renderer

Returns a new instance of Renderer.



3
4
5
6
# File 'lib/opml2html/renderer.rb', line 3

def initialize(document, css:)
  @document = document
  @css = css
end

Instance Method Details

#body_outline_created(time) ⇒ Object



76
77
78
# File 'lib/opml2html/renderer.rb', line 76

def body_outline_created(time)
  # @document.body.add_child("<p style='text-align: right'><small>#{time}</small></p>")
end

#body_outline_heading(value, description:, level:) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/opml2html/renderer.rb', line 45

def body_outline_heading(value, description:, level:)
  heading = @document.create_element("h#{level + 1}")
  heading.add_child(value)
  @document.main.add_child(heading)
  if description
    desc = @document.create_element("p")
    desc.content = description
    @document.main.add_child(desc)
  end
end

#body_outline_rss(fragment, xml_url, description: nil) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/opml2html/renderer.rb', line 62

def body_outline_rss(fragment, xml_url, description: nil)
  anchor = @document.create_element("a")
  anchor.add_child(fragment)
  anchor["href"] = xml_url
  par = @document.create_element("p")
  par.add_child(anchor)
  if description
    desc = @document.create_element("p")
    desc.content = description
    par.add_child(desc)
  end
  @document.main.add_child(par)
end

#body_outline_text(value) ⇒ Object



56
57
58
59
60
# File 'lib/opml2html/renderer.rb', line 56

def body_outline_text(value)
  par = @document.create_element("p")
  par.add_child(value)
  @document.main.add_child(par)
end

#head_date_created(time) ⇒ Object



18
19
20
# File 'lib/opml2html/renderer.rb', line 18

def head_date_created(time)
  @document..add_child("created: #{time}<br/>")
end

#head_date_modified(time) ⇒ Object



30
31
32
# File 'lib/opml2html/renderer.rb', line 30

def head_date_modified(time)
  @document..add_child("modified: #{time}<br/>")
end

#head_docsObject



38
# File 'lib/opml2html/renderer.rb', line 38

def head_docs(*); end

#head_endObject



40
41
42
43
# File 'lib/opml2html/renderer.rb', line 40

def head_end
  @document.head.add_child("<link rel=\"stylesheet\" href=\"#{ @css }\"/>")
  @document.main.add_child(@document.)
end

#head_owner_email(content) ⇒ Object



34
35
36
# File 'lib/opml2html/renderer.rb', line 34

def head_owner_email(content)
  @document..add_child("owner email: #{content}")
end

#head_owner_name(content) ⇒ Object



26
27
28
# File 'lib/opml2html/renderer.rb', line 26

def head_owner_name(content)
  @document..add_child("owner: #{content}<br/>")
end

#head_owner_twitter_screen_name(content) ⇒ Object



22
23
24
# File 'lib/opml2html/renderer.rb', line 22

def head_owner_twitter_screen_name(content)
  @document..add_child("Twitter: #{content}<br/>")
end

#head_title(content) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/opml2html/renderer.rb', line 8

def head_title(content)
  title = @document.create_element("title")
  title.content = content
  @document.head.add_child(title)

  heading = @document.create_element("h1")
  heading.content = content
  @document.main.add_child(heading)
end