class Kbt::Template

Attributes

file_path[R]
key[R]

Public Class Methods

new(file_path, key = nil) click to toggle source
# File lib/kbt/template.rb, line 5
def initialize(file_path, key = nil)
  @file_path = file_path.to_s =~ /.yml$/ ? file_path : "#{file_path}.yml"
  @key = key
end

Public Instance Methods

file_content() click to toggle source
# File lib/kbt/template.rb, line 14
def file_content
  @file_content ||= File.read(file_path)
end
keys() click to toggle source
# File lib/kbt/template.rb, line 18
def keys
  key ? key.split('.') : nil
end
value() click to toggle source
# File lib/kbt/template.rb, line 22
def value
  return yml unless keys
  keys.inject(yml) do |prev, nxt|
    prev[nxt]
  end
end
yml() click to toggle source
# File lib/kbt/template.rb, line 10
def yml
  @yml ||= YAML.load(file_content)
end