Class: Ropet::Config

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

Overview

Customizes parser settings

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Config) initialize

Sets @defaults and default @false_prefix



14
15
16
17
# File 'lib/ropet/config.rb', line 14

def initialize
  @defaults = {}
  @false_prefix = 'no_'
end

Instance Attribute Details

- (Hash) defaults (readonly)

Keeps all the defaults to use when there's no value assigned



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

def defaults
  @defaults
end

- (String) false_prefix (readonly)

Stores prefix to match false flags with



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

def false_prefix
  @false_prefix
end

Class Method Details

+ (Config) from_dsl(&block)

Creates new instance of Config and executes dsl methods on it



23
24
25
26
27
# File 'lib/ropet/config.rb', line 23

def self.from_dsl(&block)
  c = self.new
  c.instance_exec(&block)
  return c
end

Instance Method Details

- (nil) default(key, value)

Adds a default `value` for `key`



33
34
35
36
# File 'lib/ropet/config.rb', line 33

def default(key, value)
  @defaults[key.to_sym] = value
  return nil
end

- (nil) prefix(prefix)

Sets the false prefix for a parser



41
42
43
44
# File 'lib/ropet/config.rb', line 41

def prefix(prefix)
  @false_prefix = prefix.to_s
  return nil
end