Class: Bandoleer::Outfitter

Inherits:
Thor::Group
  • Object
show all
Includes:
ErbHelper, Thor::Actions
Defined in:
lib/bandoleer/outfitter.rb

Overview

Generator for bandoleer template files.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ErbHelper

#fill_erb_template, included

Instance Attribute Details

#const_arrObject (readonly)

Returns the value of attribute const_arr.



11
12
13
# File 'lib/bandoleer/outfitter.rb', line 11

def const_arr
  @const_arr
end

#contentObject (readonly)

Returns the value of attribute content.



11
12
13
# File 'lib/bandoleer/outfitter.rb', line 11

def content
  @content
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



11
12
13
# File 'lib/bandoleer/outfitter.rb', line 11

def file_name
  @file_name
end

#vialsObject (readonly)

Returns the value of attribute vials.



11
12
13
# File 'lib/bandoleer/outfitter.rb', line 11

def vials
  @vials
end

Instance Method Details

#craft_bandoleerObject

Create and populate a bandoleer template file using assigned variables.



23
24
25
26
27
28
# File 'lib/bandoleer/outfitter.rb', line 23

def craft_bandoleer
  @vials   = format_vials
  @content = fill_erb_template('vials')
  wrap_content
  template '%file_name%.rb.tt'
end

#prepare_materialsObject

Assign instance variables needed for crafting a fresh bandoleer.



16
17
18
19
20
# File 'lib/bandoleer/outfitter.rb', line 16

def prepare_materials
  @const_arr = const_name.split('/')
  @file_name = const_arr.last
  @const_arr.map! {|const| const.split('_').map(&:capitalize).join }
end