Class: Hearthstone::Log::Configurator
- Inherits:
-
Object
- Object
- Hearthstone::Log::Configurator
- Defined in:
- lib/hearthstone/log/configurator.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #configure ⇒ Object
-
#initialize(path = "~/Library/Preferences/Blizzard/Hearthstone/log.config") ⇒ Configurator
constructor
A new instance of Configurator.
- #needs_config? ⇒ Boolean
Constructor Details
#initialize(path = "~/Library/Preferences/Blizzard/Hearthstone/log.config") ⇒ Configurator
Returns a new instance of Configurator.
6 7 8 |
# File 'lib/hearthstone/log/configurator.rb', line 6 def initialize(path="~/Library/Preferences/Blizzard/Hearthstone/log.config") @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/hearthstone/log/configurator.rb', line 4 def path @path end |
Instance Method Details
#configure ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hearthstone/log/configurator.rb', line 19 def configure config = """[Zone] LogLevel=1 FilePrinting=false ConsolePrinting=true ScreenPrinting=false [Power] LogLevel=1 ConsolePrinting=true """ mode = "w" if File.exists?(path) mode = "a" end File.open(path, mode) do |f| f.write(config) end end |
#needs_config? ⇒ Boolean
10 11 12 13 14 15 16 17 |
# File 'lib/hearthstone/log/configurator.rb', line 10 def needs_config? unless File.exists?(path) return true end data = File.read(path) !(data =~ /\[Zone\]/ && data =~ /\[Power\]/) end |