Class: Tsumetogi::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/tsumetogi/config.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  resolution: 150,
  crop_x: 0,
  crop_y: 0,
  crop_w: 0,
  crop_h: 0,
  diff_strategy: "Digest",
  verbose: false,
  progress: true,
  text: true,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/tsumetogi/config.rb', line 27

def initialize(options = {})
  config_path = options[:config]
  if config_path
    config = YAML.load(File.read(config_path))
    config && config.each do |k, v|
      writer_method = "#{k}="
      if self.respond_to?(writer_method)
        self.send(writer_method, v) 
      else
        warn "Unknown config item found: #{k}"
      end
    end
  end

  # set option-specified or default values
  DEFAULT_OPTIONS.each do |k, v|
    self.send("#{k}=", options[k] || v) if instance_variable_get("@#{k}").nil?
  end
end

Instance Attribute Details

#crop_hObject

Returns the value of attribute crop_h.



7
8
9
# File 'lib/tsumetogi/config.rb', line 7

def crop_h
  @crop_h
end

#crop_wObject

Returns the value of attribute crop_w.



7
8
9
# File 'lib/tsumetogi/config.rb', line 7

def crop_w
  @crop_w
end

#crop_xObject

Returns the value of attribute crop_x.



7
8
9
# File 'lib/tsumetogi/config.rb', line 7

def crop_x
  @crop_x
end

#crop_yObject

Returns the value of attribute crop_y.



7
8
9
# File 'lib/tsumetogi/config.rb', line 7

def crop_y
  @crop_y
end

#diff_strategyObject

Returns the value of attribute diff_strategy.



9
10
11
# File 'lib/tsumetogi/config.rb', line 9

def diff_strategy
  @diff_strategy
end

#images_dirObject

Returns the value of attribute images_dir.



8
9
10
# File 'lib/tsumetogi/config.rb', line 8

def images_dir
  @images_dir
end

#progressObject

Returns the value of attribute progress.



11
12
13
# File 'lib/tsumetogi/config.rb', line 11

def progress
  @progress
end

#resolutionObject

Returns the value of attribute resolution.



6
7
8
# File 'lib/tsumetogi/config.rb', line 6

def resolution
  @resolution
end

#textObject

Returns the value of attribute text.



12
13
14
# File 'lib/tsumetogi/config.rb', line 12

def text
  @text
end

#text_pathObject

Returns the value of attribute text_path.



13
14
15
# File 'lib/tsumetogi/config.rb', line 13

def text_path
  @text_path
end

#verboseObject

Returns the value of attribute verbose.



10
11
12
# File 'lib/tsumetogi/config.rb', line 10

def verbose
  @verbose
end