Class: GeoPattern::GeoPatternTask
- Defined in:
- lib/geo_pattern/geo_pattern_task.rb
Overview
GeoPatternTask
Instance Attribute Summary collapse
-
#allowed_patterns ⇒ Object
readonly
Returns the value of attribute allowed_patterns.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Attributes inherited from RakeTask
#description, #name, #verbose, #verbose (true)
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ GeoPatternTask
constructor
Create a new geo pattern task.
- #run_task(_verbose) ⇒ Object
Methods inherited from RakeTask
Constructor Details
#initialize(opts = {}) ⇒ GeoPatternTask
Create a new geo pattern task
27 28 29 30 31 32 33 34 |
# File 'lib/geo_pattern/geo_pattern_task.rb', line 27 def initialize(opts = {}) super fail ArgumentError, :data if [:data].nil? @data = [:data] @allowed_patterns = [:allowed_patterns] end |
Instance Attribute Details
#allowed_patterns ⇒ Object (readonly)
Returns the value of attribute allowed_patterns.
15 16 17 |
# File 'lib/geo_pattern/geo_pattern_task.rb', line 15 def allowed_patterns @allowed_patterns end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/geo_pattern/geo_pattern_task.rb', line 11 def data @data end |
Instance Method Details
#run_task(_verbose) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/geo_pattern/geo_pattern_task.rb', line 37 def run_task(_verbose) data.each do |path, string| opts = {} path = File.(path) if string.is_a?(Hash) input = string[:input] opts[:patterns] = string[:patterns] if string.key? :patterns opts[:color] = string[:color] if string.key? :color opts[:base_color] = string[:base_color] if string.key? :base_color else fail 'Invalid data structure for Rake Task' end pattern = GeoPattern.generate(input, opts) logger.info "Creating pattern at \"#{path}\"." FileUtils.mkdir_p File.dirname(path) File.write(path, pattern.to_svg) end end |