Class: Githug::Profile
- Inherits:
-
Object
show all
- Defined in:
- lib/githug/profile.rb
Constant Summary
collapse
- PROFILE_FILE =
".profile.yml"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(settings) ⇒ Profile
Returns a new instance of Profile.
43
44
45
|
# File 'lib/githug/profile.rb', line 43
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
34
35
36
37
38
39
40
41
|
# File 'lib/githug/profile.rb', line 34
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.
7
8
9
|
# File 'lib/githug/profile.rb', line 7
def settings
@settings
end
|
Class Method Details
.load ⇒ Object
10
11
12
|
# File 'lib/githug/profile.rb', line 10
def load
self.new(settings)
end
|
Instance Method Details
#level_bump ⇒ Object
59
60
61
62
63
|
# File 'lib/githug/profile.rb', line 59
def level_bump
settings[:completed_levels] << level
settings[:current_levels] = levels
set_level(next_level)
end
|
#save ⇒ Object
47
48
49
50
51
|
# File 'lib/githug/profile.rb', line 47
def save
File.open(PROFILE_FILE, 'w') do |out|
YAML.dump(settings, out)
end
end
|
#set_level(name) ⇒ Object
53
54
55
56
57
|
# File 'lib/githug/profile.rb', line 53
def set_level(name)
settings[:level] = name
reset!
save
end
|