class Akane::Config
Public Class Methods
new(file_or_hash)
click to toggle source
# File lib/akane/config.rb, line 7 def initialize(file_or_hash) @hash = case file_or_hash when String YAML.load_file(file_or_hash) when Hash file_or_hash else raise ArgumentError, 'file_or_hash is not Hash or String' end end
Public Instance Methods
[](k)
click to toggle source
# File lib/akane/config.rb, line 18 def [](k) @hash[k.to_s] end
consumer()
click to toggle source
# File lib/akane/config.rb, line 22 def consumer consumer = self[:consumer] return nil unless consumer OAuth::Consumer.new(consumer['token'], consumer['secret'], site: 'https://api.twitter.com/') end
log_direct(line)
click to toggle source
# File lib/akane/config.rb, line 33 def log_direct(line) if @hash["log"] open(@hash["log"], 'a') do |io| io.puts line end else $stdout.puts line end end
logger()
click to toggle source
# File lib/akane/config.rb, line 29 def logger Logger.new(@hash["log"] || $stdout) end