Class: RateTheme::Logger
- Inherits:
-
Object
- Object
- RateTheme::Logger
- Defined in:
- lib/rate_theme/monitor.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
Instance Method Summary collapse
- #action ⇒ Object
- #file_exist ⇒ Object
- #file_virgin ⇒ Object
-
#initialize(args) ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize(args) ⇒ Logger
Returns a new instance of Logger.
4 5 6 7 8 |
# File 'lib/rate_theme/monitor.rb', line 4 def initialize(args) @name = args.fetch(:name) = args.fetch(:rating) @file = File.("../themes.yml", __FILE__) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rate_theme/monitor.rb', line 3 def name @name end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
3 4 5 |
# File 'lib/rate_theme/monitor.rb', line 3 def end |
Instance Method Details
#action ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/rate_theme/monitor.rb', line 23 def action unless File.exists?(@file) self.file_virgin else self.file_exist end end |
#file_exist ⇒ Object
17 18 19 20 21 |
# File 'lib/rate_theme/monitor.rb', line 17 def file_exist data = YAML.load_file(@file) data[self.name] = self..to_i File.open(@file, 'w+') {|f| YAML.dump(data, f)} end |
#file_virgin ⇒ Object
10 11 12 13 14 15 |
# File 'lib/rate_theme/monitor.rb', line 10 def file_virgin File.open(@file, 'w') do |f| f.puts({self.name => self..to_i}.to_yaml) f.close end end |