Class: Cosmos::HandbookCreatorConfig::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/cosmos/tools/handbook_creator/handbook_creator_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, type = :NORMAL) ⇒ Page

Returns a new instance of Page.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 41

def initialize(filename, type = :NORMAL)
  @filename = filename
  @type = type
  @target_names = []
  @sections = []
  @pdf = true
  @pdf_toc = nil
  @pdf_cover_filename = nil
  @pdf_cover_title = nil
  @pdf_header_filename = nil
  @pdf_header_title = nil
  @pdf_footer_filename = nil
  @pdf_footer_title = nil
  @pdf_top_margin = 20
  @pdf_bottom_margin = 15
  @pdf_side_margin = 10
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



25
26
27
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 25

def filename
  @filename
end

#pdfObject

Returns the value of attribute pdf.



29
30
31
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 29

def pdf
  @pdf
end

#pdf_bottom_marginObject

Returns the value of attribute pdf_bottom_margin.



38
39
40
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 38

def pdf_bottom_margin
  @pdf_bottom_margin
end

#pdf_cover_filenameObject

Returns the value of attribute pdf_cover_filename.



30
31
32
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 30

def pdf_cover_filename
  @pdf_cover_filename
end

#pdf_cover_titleObject

Returns the value of attribute pdf_cover_title.



31
32
33
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 31

def pdf_cover_title
  @pdf_cover_title
end

Returns the value of attribute pdf_footer_filename.



34
35
36
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 34

def pdf_footer_filename
  @pdf_footer_filename
end

Returns the value of attribute pdf_footer_title.



35
36
37
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 35

def pdf_footer_title
  @pdf_footer_title
end

#pdf_header_filenameObject

Returns the value of attribute pdf_header_filename.



32
33
34
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 32

def pdf_header_filename
  @pdf_header_filename
end

#pdf_header_titleObject

Returns the value of attribute pdf_header_title.



33
34
35
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 33

def pdf_header_title
  @pdf_header_title
end

#pdf_side_marginObject

Returns the value of attribute pdf_side_margin.



39
40
41
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 39

def pdf_side_margin
  @pdf_side_margin
end

#pdf_tocObject

Returns the value of attribute pdf_toc.



36
37
38
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 36

def pdf_toc
  @pdf_toc
end

#pdf_top_marginObject

Returns the value of attribute pdf_top_margin.



37
38
39
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 37

def pdf_top_margin
  @pdf_top_margin
end

#sectionsObject (readonly)

Returns the value of attribute sections.



28
29
30
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 28

def sections
  @sections
end

#target_namesObject (readonly)

Returns the value of attribute target_names.



27
28
29
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 27

def target_names
  @target_names
end

#typeObject (readonly)

Returns the value of attribute type.



26
27
28
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 26

def type
  @type
end

Instance Method Details

#add_section(section) ⇒ Object



64
65
66
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 64

def add_section(section)
  @sections << section
end

#add_target_name(target_name) ⇒ Object



59
60
61
62
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 59

def add_target_name(target_name)
  @target_names << target_name.upcase
  @target_names.uniq!
end

#create_html(hide_ignored) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 68

def create_html(hide_ignored)
  @hide_ignored = hide_ignored
  Cosmos.set_working_dir do
    if @type == :TARGETS
      target_names = @target_names
      target_names = System.commands.target_names | System.telemetry.target_names if @target_names.empty?
      target_names.each {|target_name| create_file(target_name.downcase + @filename, [target_name], true, :HTML)}
    else # @type == :NORMAL
      create_file(@filename, @target_names, false, :HTML)
    end
  end
end

#create_pdf(hide_ignored, progress_dialog = nil) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/cosmos/tools/handbook_creator/handbook_creator_config.rb', line 81

def create_pdf(hide_ignored, progress_dialog = nil)
  @hide_ignored = hide_ignored
  if @pdf
    if progress_dialog
      Qt.execute_in_main_thread(true) do
        progress_dialog.set_text_font(Cosmos.get_default_font)
      end
    end
    Cosmos.set_working_dir do
      if @type == :TARGETS
        target_names = @target_names
        target_names = System.commands.target_names | System.telemetry.target_names if @target_names.empty?
        target_names.each do |target_name|
          create_pdf_file(progress_dialog, target_name)
        end
      else # @type == :NORMAL
        create_pdf_file(progress_dialog)
      end
    end
  end
end