Class: Prawn::Svg::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/svg/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, element, parent_calls, state) ⇒ Element

Returns a new instance of Element


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/prawn/svg/element.rb', line 5

def initialize(document, element, parent_calls, state)
  @document = document
  @element = element
  @parent_calls = parent_calls
  @state = state
  @base_calls = @calls = []

  combine_attributes_and_style_declarations
  apply_styles

  if id = @attributes["id"]
    document.elements_by_id[id] = self
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes


2
3
4
# File 'lib/prawn/svg/element.rb', line 2

def attributes
  @attributes
end

#base_callsObject (readonly)

Returns the value of attribute base_calls


2
3
4
# File 'lib/prawn/svg/element.rb', line 2

def base_calls
  @base_calls
end

#callsObject

Returns the value of attribute calls


3
4
5
# File 'lib/prawn/svg/element.rb', line 3

def calls
  @calls
end

#documentObject (readonly)

Returns the value of attribute document


2
3
4
# File 'lib/prawn/svg/element.rb', line 2

def document
  @document
end

#elementObject (readonly)

Returns the value of attribute element


2
3
4
# File 'lib/prawn/svg/element.rb', line 2

def element
  @element
end

#parent_callsObject (readonly)

Returns the value of attribute parent_calls


2
3
4
# File 'lib/prawn/svg/element.rb', line 2

def parent_calls
  @parent_calls
end

#stateObject (readonly)

Returns the value of attribute state


2
3
4
# File 'lib/prawn/svg/element.rb', line 2

def state
  @state
end

Instance Method Details

#add_call(name, *arguments) ⇒ Object


34
35
36
# File 'lib/prawn/svg/element.rb', line 34

def add_call(name, *arguments)
  @calls << [name.to_s, arguments, []]
end

#add_call_and_enter(name, *arguments) ⇒ Object


38
39
40
41
# File 'lib/prawn/svg/element.rb', line 38

def add_call_and_enter(name, *arguments)
  @calls << [name.to_s, arguments, []]
  @calls = @calls.last.last
end

#add_calls_from_element(other) ⇒ Object


47
48
49
# File 'lib/prawn/svg/element.rb', line 47

def add_calls_from_element(other)
  @calls.concat other.base_calls
end

#append_calls_to_parentObject


43
44
45
# File 'lib/prawn/svg/element.rb', line 43

def append_calls_to_parent
  @parent_calls.concat(@base_calls)
end

#each_child_elementObject


24
25
26
27
28
# File 'lib/prawn/svg/element.rb', line 24

def each_child_element
  element.elements.each do |e|
    yield self.class.new(@document, e, @calls, @state.dup)
  end
end

#nameObject


20
21
22
# File 'lib/prawn/svg/element.rb', line 20

def name
  @name ||= element.name
end

#warningsObject


30
31
32
# File 'lib/prawn/svg/element.rb', line 30

def warnings
  @document.warnings
end