Class: Hieroglyph::CharacterSheet

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

Constant Summary collapse

@@montage_args =
{
  '-background' => '#ffffff',
  '-fill' => '#000000',
  '-mattecolor' => '#ffffff',
  '-geometry' => '150x150+25+25',
  '-label' => '%t'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CharacterSheet

Returns a new instance of CharacterSheet.



17
18
19
20
21
22
# File 'lib/hieroglyph/character_sheet.rb', line 17

def initialize(options)
  @options = options
  @output_path = File.join(@options[:output_folder], @options[:name]) + '_characters.png'
  Hieroglyph.delete @output_path
  @files = []
end

Instance Attribute Details

#filesObject

Returns the value of attribute files.



7
8
9
# File 'lib/hieroglyph/character_sheet.rb', line 7

def files
  @files
end

#output_pathObject

Returns the value of attribute output_path.



7
8
9
# File 'lib/hieroglyph/character_sheet.rb', line 7

def output_path
  @output_path
end

Instance Method Details

#add(file) ⇒ Object



24
25
26
# File 'lib/hieroglyph/character_sheet.rb', line 24

def add(file)
  @files.push file
end

#saveObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/hieroglyph/character_sheet.rb', line 28

def save
  cmd = ['montage']
  @@montage_args['title'] = @options[:name]
  @@montage_args.each do |arg, value|
    cmd.push arg
    cmd.push value
  end
  @files.each do |file|
    cmd.push file
  end
  cmd.push @output_path
  cmd = Escape.shell_command(cmd)
  system(cmd)
  Hieroglyph.success "Character sheet saved: #{File.expand_path(@options[:output_folder])}/#{@options[:name]}_characters.svg"
end