class Selfiegram::Runner::Options
Attributes
action[RW]
background_image_path[RW]
image[RW]
magic[RW]
output_path[RW]
selfiegram_path[RW]
user[RW]
verbose[RW]
Public Class Methods
new(options={})
click to toggle source
# File lib/runner/options/options.rb, line 8 def initialize(options={}) @user = pathify options[:user] @magic = options[:magic] || "" @action = options[:action] || :snap @image = options[:image] @verbose = options[:verbose] @selfiegram_path = options[:path] || default_selfiegram_path @output_path = default_output_path(options[:output]) @background_image_path = default_background_image_path end
Public Instance Methods
each(&block)
click to toggle source
# File lib/runner/options/options.rb, line 27 def each(&block) to_h.each(&block) end
to_h()
click to toggle source
# File lib/runner/options/options.rb, line 19 def to_h instance_variables.inject({}) do |hash, var_name| getter = var_name.to_s[1..-1].to_sym hash[getter] = send(getter) hash end end
Private Instance Methods
absolute_path(relative_path)
click to toggle source
# File lib/runner/options/options.rb, line 53 def absolute_path(relative_path) File.expand_path(File.join(Runner.root, relative_path)) end
default_background_image_path()
click to toggle source
# File lib/runner/options/options.rb, line 41 def default_background_image_path File.expand_path(File.join("#{output_path}", "../background.png")) end
default_output_path(output_path)
click to toggle source
# File lib/runner/options/options.rb, line 36 def default_output_path(output_path) output_path ||= Runner.root File.expand_path(File.join(output_path, "tmp/#{magic_path}/final.png")) end
default_selfiegram_path()
click to toggle source
# File lib/runner/options/options.rb, line 32 def default_selfiegram_path absolute_path "selfies/people/#{user}.png" end
magic_path()
click to toggle source
# File lib/runner/options/options.rb, line 45 def magic_path pathify(magic) end
pathify(string)
click to toggle source
# File lib/runner/options/options.rb, line 49 def pathify(string) string.split(" ").join("_").downcase end