Class: Redis::Stream::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/stream/config.rb

Overview

Simple way to read and manage a config.yml file

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object

get the value for a key

Parameters:

  • key (String)

    key of key/value

Returns:

  • (Object)

    value of key/value pair



38
39
40
41
# File 'lib/redis/stream/config.rb', line 38

def self.[](key)
  init
  @config[key]
end

.[]=(key, value) ⇒ Object

set a value into the config.yml file

Parameters:

  • key (String)
  • value (Object)

Returns:

  • (Object)


47
48
49
50
51
52
53
# File 'lib/redis/stream/config.rb', line 47

def self.[]=(key, value)
  init
  @config[key] = value
  File.open("#{path}/#{name}", 'w') do |f|
    f.puts @config.to_yaml
  end
end

.include?(key) ⇒ Boolean

is key available in config store

Parameters:

  • key (String)

    key to lookup

Returns:

  • (Boolean)


58
59
60
61
# File 'lib/redis/stream/config.rb', line 58

def self.include?(key)
  init
  @config.include?(key)
end

.nameString

get name of config file

Returns:

  • (String)

    get name of config file



13
14
15
# File 'lib/redis/stream/config.rb', line 13

def self.name
  @config_file_name
end

.name=(config_file_name) ⇒ Object

set config file name defaults to config.yml

Parameters:

  • config_file_name (String)

    Name of config file



19
20
21
# File 'lib/redis/stream/config.rb', line 19

def self.name=(config_file_name)
  @config_file_name = config_file_name
end

.pathString

return the current location of the config.yml file

Returns:

  • (String)

    path of config.yml



25
26
27
# File 'lib/redis/stream/config.rb', line 25

def self.path
  @config_file_path
end

.path=(config_file_path) ⇒ Object

set path to config file

Parameters:

  • config_file_path (String)

    path to config.yml file



31
32
33
# File 'lib/redis/stream/config.rb', line 31

def self.path=(config_file_path)
  @config_file_path = config_file_path
end