Class: Rubyword::Element::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyword/element/section.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(section_count, style = nil, rubyword = nil) ⇒ Section

Returns a new instance of Section.



15
16
17
18
19
20
21
22
# File 'lib/rubyword/element/section.rb', line 15

def initialize(section_count, style = nil, rubyword=nil)
				@section_id = section_count
				@style = style
  @rubyword = rubyword
  @section_objects = []
  @objects = []
  @text_blocks = []
end

Instance Attribute Details

#objectsObject

Returns the value of attribute objects.



13
14
15
# File 'lib/rubyword/element/section.rb', line 13

def objects
  @objects
end

#rubywordObject

Returns the value of attribute rubyword.



13
14
15
# File 'lib/rubyword/element/section.rb', line 13

def rubyword
  @rubyword
end

#section_idObject

Returns the value of attribute section_id.



13
14
15
# File 'lib/rubyword/element/section.rb', line 13

def section_id
  @section_id
end

#section_objectsObject

Returns the value of attribute section_objects.



13
14
15
# File 'lib/rubyword/element/section.rb', line 13

def section_objects
  @section_objects
end

#styleObject

Returns the value of attribute style.



13
14
15
# File 'lib/rubyword/element/section.rb', line 13

def style
  @style
end

#titlesObject

Returns the value of attribute titles.



13
14
15
# File 'lib/rubyword/element/section.rb', line 13

def titles
  @titles
end

Instance Method Details

#image(url) ⇒ Object



60
61
62
63
64
# File 'lib/rubyword/element/section.rb', line 60

def image(url)
  object ||= Image.new(@rubyword)
  object.save(url)
  @objects << object
end


54
55
56
57
58
# File 'lib/rubyword/element/section.rb', line 54

def link(text, link, style=nil)
  object ||= Link.new(@rubyword)
  object.save(text, link, style)
  @objects << object
end

#list(text, level, style = nil) ⇒ Object



48
49
50
51
52
# File 'lib/rubyword/element/section.rb', line 48

def list(text, level, style=nil)
  object ||= List.new(@rubyword)
  object.save(text, level, style)
  @objects << object
end

#p(style = nil, &block) ⇒ Object



24
25
26
27
28
29
# File 'lib/rubyword/element/section.rb', line 24

def p(style=nil, &block)
  object ||= Paragraph.new(@rubyword, self, style)
  return nil unless block_given?
  object.instance_eval(&block) 
  @objects << object
end

#page_break(break_num = 1) ⇒ Object



66
67
68
69
70
# File 'lib/rubyword/element/section.rb', line 66

def page_break(break_num=1)
  object ||= PageBreak.new(@rubyword)
  object.save(break_num)
  @objects << object
end

#table(style = nil, &block) ⇒ Object



31
32
33
34
35
36
# File 'lib/rubyword/element/section.rb', line 31

def table(style=nil, &block)
  object ||= Table.new(@rubyword, self, style)
  return nil unless block_given?
  object.instance_eval(&block)
  @objects << object
end

#text(text, style = nil) ⇒ Object Also known as: title_1, title_2, title_3, title_4



38
39
40
41
42
# File 'lib/rubyword/element/section.rb', line 38

def text(text, style=nil)
     object ||= Text.new(@rubyword, self)
     object.save(text, __callee__.to_s, style)
     @objects << object
end

#text_break(break_num = 1) ⇒ Object



72
73
74
75
76
# File 'lib/rubyword/element/section.rb', line 72

def text_break(break_num=1)
  object ||= TextBreak.new(@rubyword)
  object.save(break_num)
  @objects << object
end