Class: Gitscrub::Profile
- Inherits:
-
Object
- Object
- Gitscrub::Profile
- Defined in:
- lib/gitscrub/profile.rb
Constant Summary collapse
- PROFILE_FILE =
".profile.yml"
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(settings) ⇒ Profile
constructor
A new instance of Profile.
- #method_missing(method, *args, &block) ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(settings) ⇒ Profile
Returns a new instance of Profile.
29 30 31 |
# File 'lib/gitscrub/profile.rb', line 29 def initialize(settings) @settings = settings end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/gitscrub/profile.rb', line 20 def method_missing(method, *args, &block) if method.to_s.end_with?("=") method = method.to_s.chop.to_sym return settings[method] = args[0] if settings.include?(method) end return(settings[method]) if settings.include?(method) super end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
6 7 8 |
# File 'lib/gitscrub/profile.rb', line 6 def settings @settings end |
Class Method Details
.load ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/gitscrub/profile.rb', line 9 def load settings = { :level => 0 } settings.merge! YAML::load(File.open(PROFILE_FILE)) if File.exists?(PROFILE_FILE) self.new(settings) end |
Instance Method Details
#save ⇒ Object
33 34 35 36 37 |
# File 'lib/gitscrub/profile.rb', line 33 def save File.open(PROFILE_FILE, 'w') do |out| YAML.dump(settings, out) end end |