class DotUsage::DotUsageFile
Public Class Methods
new(filename)
click to toggle source
# File lib/dot_usage.rb, line 9 def initialize(filename) @filename = filename @data = YAML.load_file filename end
Public Instance Methods
recipe(target)
click to toggle source
# File lib/dot_usage.rb, line 18 def recipe(target) content = @data[target] if content.instance_of? Array content elsif content.instance_of? String [content] elsif content.instance_of? Hash unless 1 == content.length STDERR.puts content STDERR.puts 'Error: hash may only have one entry!' return 1 end md = MarkdownFile.new content.keys.first md.snippet content.values.first else STDERR.puts content STDERR.puts 'Error: invalid recipe!' 1 end end
targets()
click to toggle source
# File lib/dot_usage.rb, line 14 def targets @data.keys end