Class: FPM::RakeTask::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/rake_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(defaults = nil) ⇒ Options

Returns a new instance of Options.



9
10
11
12
13
14
15
# File 'lib/fpm/rake_task.rb', line 9

def initialize(defaults=nil)
  if defaults.nil?
    @h = Hash.new
  else
    @h = defaults
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/fpm/rake_task.rb', line 17

def method_missing(m, *args)
  if m.end_with?("=")
    raise ArgumentError, "#{self.class.name}##{m} ... Expected 1 arg, got #{args.length}" if args.length != 1
    @h[m[0...-1]] = args[0]
  else
    raise ArgumentError, "Expected 0 arg, got #{args.length}" if args.length != 0
    return @h[m]
  end
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



7
8
9
# File 'lib/fpm/rake_task.rb', line 7

def args
  @args
end

Instance Method Details

#to_hObject



27
28
29
# File 'lib/fpm/rake_task.rb', line 27

def to_h
  return @h
end