class Mru::Fuf::Data
Public Class Methods
load(type, limit: 1000, reverse: false)
click to toggle source
# File lib/mru/fuf/data.rb, line 5 def self.load(type, limit: 1000, reverse: false) path = path_of_type(type) raise "Nothing Dir: [#{DIR}]" unless Dir.exist? DIR raise "Nothing File: #{path}" unless File.readable? path range = reverse ? (limit * -1)..-1 : 0..limit buf = [] IO.readlines(path)[range].tap{|x| break x.reverse if reverse }.each do |line| buf << YAML.load(line)['word'] end buf end
path_of_type(type)
click to toggle source
# File lib/mru/fuf/data.rb, line 19 def self.path_of_type(type) "#{DIR}/#{type}" end