Class: Gitabu::Builder

Inherits:
Object
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/gitabu/builder.rb

Overview

Builder class for files given target and template.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name, items, target, template, version) ⇒ Builder

Returns a new instance of Builder.



17
18
19
20
21
22
23
# File 'lib/gitabu/builder.rb', line 17

def initialize(class_name, items, target, template, version)
  @class_name = class_name
  @items      = items
  @target     = target
  @template   = template
  @version    = version
end

Instance Attribute Details

#class_nameObject

Returns the value of attribute class_name.



11
12
13
# File 'lib/gitabu/builder.rb', line 11

def class_name
  @class_name
end

#itemsObject

Returns the value of attribute items.



11
12
13
# File 'lib/gitabu/builder.rb', line 11

def items
  @items
end

#targetObject

Returns the value of attribute target.



11
12
13
# File 'lib/gitabu/builder.rb', line 11

def target
  @target
end

#templateObject

Returns the value of attribute template.



11
12
13
# File 'lib/gitabu/builder.rb', line 11

def template
  @template
end

#versionObject

Returns the value of attribute version.



11
12
13
# File 'lib/gitabu/builder.rb', line 11

def version
  @version
end

Class Method Details

.save(class_name:, items:, target:, template:, version:) ⇒ Object



13
14
15
# File 'lib/gitabu/builder.rb', line 13

def self.save(class_name:, items:, target:, template:, version:)
  new(class_name, items, target, template, version).save
end

Instance Method Details

#saveObject



25
26
27
28
29
# File 'lib/gitabu/builder.rb', line 25

def save
  File.open(target, "w+") do |f|
    f.write(render)
  end
end