Class: Yadtfp::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/yadtfp/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Initializes @filter, @parser, and @outputter to their defaults based on the following table:

filter = '*' parser = :ox outputter = :pretty



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/yadtfp/configuration.rb', line 20

def initialize
  # Path to begin traversing the input XML from
  @filter         = '*'



  # Parser
  @parser         = :ox



  # Diff result output formatter
  @outputter      = :pretty
end

Instance Attribute Details

#filterObject

Returns the value of attribute filter.



10
11
12
# File 'lib/yadtfp/configuration.rb', line 10

def filter
  @filter
end

#outputterObject

Returns the value of attribute outputter.



11
12
13
# File 'lib/yadtfp/configuration.rb', line 11

def outputter
  @outputter
end

#parserObject

Returns the value of attribute parser.



11
12
13
# File 'lib/yadtfp/configuration.rb', line 11

def parser
  @parser
end

Class Method Details

.parse_options(options = {}) ⇒ Object

Parses options, prepares this configuration instance and return the same.

Assigns default values to each configuration attributes as defined in the initialize method.

Raises ArugmentError if options is not a hash

Raises:

  • (ArgumentError)


70
71
72
73
74
75
76
77
78
79
# File 'lib/yadtfp/configuration.rb', line 70

def self.parse_options(options = {})
  raise ArgumentError, "Invalid options hash" if !options.is_a?(::Hash)

  config = self.instance
  config.filter = options[:filter] || '*'
  config.parser = options[:parser] || :ox
  config.outputter = options[:outputter] || :pretty

  config
end