Module: Easy_Set::Singleton_Methods
- Defined in:
- lib/easy_set.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #display ⇒ Object
- #generate_rand_string(length = nil) ⇒ Object
- #load_config_from(path) ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#[](key) ⇒ Object
7 8 9 |
# File 'lib/easy_set.rb', line 7 def [](key) @store[key] end |
#[]=(key, value) ⇒ Object
11 12 13 |
# File 'lib/easy_set.rb', line 11 def []=(key,value) @store[key] = value end |
#display ⇒ Object
15 16 17 |
# File 'lib/easy_set.rb', line 15 def display @store.inspect end |
#generate_rand_string(length = nil) ⇒ Object
19 20 21 22 |
# File 'lib/easy_set.rb', line 19 def generate_rand_string(length=nil) o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten return (0...(length||32)).map { o[rand(o.length)] }.join end |
#load_config_from(path) ⇒ Object
24 25 26 |
# File 'lib/easy_set.rb', line 24 def load_config_from path @store[:config] = YAML.load_file(path) end |
#to_s ⇒ Object
28 29 30 31 32 33 |
# File 'lib/easy_set.rb', line 28 def to_s @store.each do |key,value| puts "#{key}: #{value.to_s}" end puts "" end |