Class: HParser::Block::Dl::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/hparser/html.rb,
lib/hparser/text.rb,
lib/hparser/latex.rb,
lib/hparser/block/dl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, description) ⇒ Item

Returns a new instance of Item.



12
13
14
15
# File 'lib/hparser/block/dl.rb', line 12

def initialize(title,description)
  @title = title
  @description = description
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



11
12
13
# File 'lib/hparser/block/dl.rb', line 11

def description
  @description
end

#titleObject (readonly)

Returns the value of attribute title.



11
12
13
# File 'lib/hparser/block/dl.rb', line 11

def title
  @title
end

Instance Method Details

#==(o) ⇒ Object



17
18
19
20
21
# File 'lib/hparser/block/dl.rb', line 17

def ==(o)
  self.class == o.class and 
    self.title == o.title and
    self.description == o.description
end

#to_htmlObject



202
203
204
205
206
# File 'lib/hparser/html.rb', line 202

def to_html
  dt = self.title.map{|x| x.to_html}.join
  dd = self.description.map{|x| x.to_html}.join
  "<dt>#{dt}</dt><dd>#{dd}</dd>"
end

#to_latexObject



142
143
144
145
146
147
# File 'lib/hparser/latex.rb', line 142

def to_latex
  dt = self.title.map{|x| x.to_latex}.join
  dd = self.description.map{|x| x.to_latex}.join

  %Q(\\item[#{dt}] \\quad \\\\\n#{dd}\n)
end

#to_textObject



97
98
99
100
101
102
103
# File 'lib/hparser/text.rb', line 97

def to_text
  dt = self.title.map{|x| x.to_html}.join
  dd = self.description.map{|x| x.to_html}.join.split("\n").map{|x|
    '  '+x
  }.join("\n")
  "#{dt}\n#{dd}"
end