Class: Technologist::YamlParser

Inherits:
Object
  • Object
show all
Defined in:
lib/technologist/yaml_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name) ⇒ YamlParser

Returns a new instance of YamlParser.



7
8
9
# File 'lib/technologist/yaml_parser.rb', line 7

def initialize(file_name)
  @file_name = file_name
end

Instance Attribute Details

#file_nameObject (readonly)

Returns the value of attribute file_name.



5
6
7
# File 'lib/technologist/yaml_parser.rb', line 5

def file_name
  @file_name
end

Instance Method Details

#rulesObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/technologist/yaml_parser.rb', line 11

def rules
  @rules ||=
    begin
      parsed_rules = from_file.map do |technology, definition|
        definition['rules'].map! do |rule|
          instancify(technology, rule)
        end

        [technology, definition]
      end

      Hash[parsed_rules]
    end
end