Module: Easy_Set::Singleton_Methods
- Defined in:
- lib/easy_set.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #display ⇒ Object
- #generate_rand_string(length = nil) ⇒ Object
- #load_config_from(path) ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#[](key) ⇒ Object
8 9 10 |
# File 'lib/easy_set.rb', line 8 def [](key) @store[key] end |
#display ⇒ Object
12 13 14 |
# File 'lib/easy_set.rb', line 12 def display @store.inspect end |
#generate_rand_string(length = nil) ⇒ Object
16 17 18 19 |
# File 'lib/easy_set.rb', line 16 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
21 22 23 |
# File 'lib/easy_set.rb', line 21 def load_config_from path @store[:config] = YAML.load_file(path) end |
#to_s ⇒ Object
25 26 27 28 29 30 |
# File 'lib/easy_set.rb', line 25 def to_s @store.each do |key,value| puts "#{key}: #{value.to_s}" end puts "" end |