class Aozora2Html::YamlLoader
YAML Loader class for Shift_JIS
Public Class Methods
new(base_dir)
click to toggle source
# File lib/aozora2html/yaml_loader.rb, line 8 def initialize(base_dir) @base_dir = base_dir end
Public Instance Methods
load(path)
click to toggle source
# File lib/aozora2html/yaml_loader.rb, line 12 def load(path) tmp_data = YAML.load_file(File.join(@base_dir, path)) normalize_data(tmp_data) end
normalize_data(data)
click to toggle source
# File lib/aozora2html/yaml_loader.rb, line 19 def normalize_data(data) case data when String data.to_sjis when Hash new_data = {} data.each do |k, v| new_data[normalize_data(k)] = normalize_data(v) end new_data when Array data.map { |item| normalize_data(item) } else # noop data end end