class Traceur::CompilationOptions

Public Class Methods

new(options = {}) click to toggle source
# File lib/traceur/compilation_options.rb, line 5
def initialize(options = {})
  @options = {}
  merge!(options)
end

Public Instance Methods

[](name) click to toggle source
# File lib/traceur/compilation_options.rb, line 14
def [](name)
  @options[normalize(name)]
end
[]=(name, value) click to toggle source
# File lib/traceur/compilation_options.rb, line 10
def []=(name, value)
  @options[normalize(name)] = value
end
each(&block) click to toggle source
# File lib/traceur/compilation_options.rb, line 29
def each(&block)
  @options.each(&block)
end
merge(options) click to toggle source
# File lib/traceur/compilation_options.rb, line 25
def merge(options)
  CompilationOptions.new(self).merge!(options)
end
merge!(options) click to toggle source
# File lib/traceur/compilation_options.rb, line 18
def merge!(options)
  options.each do |key, value|
    self[key] = value
  end
  self
end
to_hash() click to toggle source
# File lib/traceur/compilation_options.rb, line 33
def to_hash
  @options
end
to_json() click to toggle source
# File lib/traceur/compilation_options.rb, line 37
def to_json
  to_hash.to_json
end

Private Instance Methods

getter?(name, args) click to toggle source
# File lib/traceur/compilation_options.rb, line 57
def getter?(name, args)
  args.size == 0
end
method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File lib/traceur/compilation_options.rb, line 47
def method_missing(name, *args, &block)
  return self[name] = args.first if setter?(name, args)
  return self[name] if getter?(name, args)
  super
end
normalize(name) click to toggle source
# File lib/traceur/compilation_options.rb, line 61
def normalize(name)
  name.to_s.gsub(/_[a-z]/) { |m| m.upcase }.gsub('_', '').gsub(/=$/, '').to_sym
end
respond_to_missing?(name, include_private) click to toggle source
# File lib/traceur/compilation_options.rb, line 43
def respond_to_missing?(name, include_private)
  true
end
setter?(name, args) click to toggle source
# File lib/traceur/compilation_options.rb, line 53
def setter?(name, args)
  name.to_s.end_with?("=") && args.size == 1
end