Class: Html2Bbcode::Html::Element

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, Attributes
Defined in:
lib/html/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributes

has_html_attributes

Constructor Details

#initialize(element, options = {}) ⇒ Element

Returns a new instance of Element.



9
10
11
12
13
14
# File 'lib/html/element.rb', line 9

def initialize element, options = {}
  @element = element
  @options = options

  add_src_to_text if name.eql? 'img'
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



16
17
18
# File 'lib/html/element.rb', line 16

def element
  @element
end

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/html/element.rb', line 16

def options
  @options
end

Instance Method Details

#build_bbcode_elementObject



36
37
38
# File 'lib/html/element.rb', line 36

def build_bbcode_element
  bbcode_opening_tags + bbcode_content + bbcode_closing_tags
end

#font_colorObject



40
41
42
# File 'lib/html/element.rb', line 40

def font_color
  element_color.get
end

#font_sizeObject



44
45
46
# File 'lib/html/element.rb', line 44

def font_size
  get_size.to_i if get_font_size
end

#processObject



22
23
24
# File 'lib/html/element.rb', line 22

def process
  children.map(&:to_bbcode_element).join
end

#to_bbcode_elementObject



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

def to_bbcode_element
  if name == 'br'
    "\n"
  elsif element?
    build_bbcode_element
  elsif text?
    text
  end
end