Class: ProconBypassMan::Web::SettingParser

Inherits:
Object
  • Object
show all
Defined in:
lib/procon_bypass_man/web/setting_parser.rb,
lib/procon_bypass_man/web/setting_parser/layer.rb,
lib/procon_bypass_man/web/setting_parser/top_level_layer.rb

Defined Under Namespace

Classes: Layer, TopLevelLayer

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ SettingParser

Returns a new instance of SettingParser.



36
37
38
39
# File 'lib/procon_bypass_man/web/setting_parser.rb', line 36

def initialize(text)
  @parser = TopLevelLayer.new
  @parser.instance_eval(text)
end

Class Method Details

.parse(text) ⇒ Object



18
19
20
# File 'lib/procon_bypass_man/web/setting_parser.rb', line 18

def self.parse(text)
  new(text)
end

.parse_file(path) ⇒ Object



22
23
24
25
26
# File 'lib/procon_bypass_man/web/setting_parser.rb', line 22

def self.parse_file(path)
  new(
    YAML.load_file(path)&.dig("setting")
  )
end

Instance Method Details

#to_hashObject



28
29
30
# File 'lib/procon_bypass_man/web/setting_parser.rb', line 28

def to_hash
  @parser.to_hash
end

#to_hash_group_by_buttonObject



32
33
34
# File 'lib/procon_bypass_man/web/setting_parser.rb', line 32

def to_hash_group_by_button
  @parser.to_hash_group_by_button
end