Class: ODT2HTML::DeclarationBlock

Inherits:
Array
  • Object
show all
Defined in:
lib/odt2html-nsi/declaration_block.rb

Overview

Represents a CSS declaration block; a sequence of zero or more Declarations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*arglist) ⇒ DeclarationBlock

Returns a new instance of DeclarationBlock.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/odt2html-nsi/declaration_block.rb', line 7

def initialize(*arglist)
  if (arglist[0].kind_of? DeclarationBlock) then
    dblock = arglist[0]
    super( 0 )
    dblock.each do |item|
      push Declaration.new( item.property, item.value )
    end
  else
    super
  end
  @block_used = false
end

Instance Attribute Details

#block_usedObject

Returns the value of attribute block_used.



5
6
7
# File 'lib/odt2html-nsi/declaration_block.rb', line 5

def block_used
  @block_used
end

Instance Method Details

#has_top_border?Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/odt2html-nsi/declaration_block.rb', line 20

def has_top_border?
result = detect {|item| item.property =~ /border(-top)?/}
  return (result != nil) ? true : nil
end

#to_sObject



25
26
27
28
29
30
31
32
# File 'lib/odt2html-nsi/declaration_block.rb', line 25

def to_s
  result = "{\n"
  sort{|a,b| a.property <=> b.property }.each { |item|
    result << "\t#{item.property}: #{item.value};\n"
  }
  result << "}\n"
  return result
end