Class: AsciiPress::Renderer::Rendering

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html, doc, data) ⇒ Rendering

Returns a new instance of Rendering.



25
26
27
28
29
# File 'lib/ascii_press.rb', line 25

def initialize(html, doc, data)
  @html = html
  @doc = doc
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#docObject (readonly)

Returns the value of attribute doc.



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

def doc
  @doc
end

#htmlObject (readonly)

Returns the value of attribute html.



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

def html
  @html
end

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
end

Instance Method Details

#attribute_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


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

def attribute_exists?(name)
  doc.attributes.key?(name.to_s)
end

#attribute_value(name, default = nil) ⇒ Object



31
32
33
# File 'lib/ascii_press.rb', line 31

def attribute_value(name, default = nil)
  doc.attributes[name.to_s] || default
end

#list_attribute_value(name, default = []) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/ascii_press.rb', line 35

def list_attribute_value(name, default = [])
  value = attribute_value(name, :VALUE_DOES_NOT_EXIST)
  if value == :VALUE_DOES_NOT_EXIST
    default
  else
    value.split(/\s*,\s*/)
  end
end