class JpStations::List
Constants
- JP_STATION_FILE_PATH
Attributes
kana[RW]
kanji[RW]
Public Class Methods
all()
click to toggle source
# File lib/jp_stations.rb, line 15 def self.all data.map { |value| build(value) } end
build(obj_station)
click to toggle source
# File lib/jp_stations.rb, line 19 def self.build(obj_station) station = new station.kanji = obj_station[:kanji] station.kana = obj_station[:kana] station end
data()
click to toggle source
# File lib/jp_stations.rb, line 10 def self.data filepath = File.join(File.dirname(__FILE__), JP_STATION_FILE_PATH) YAML.load_file(filepath) end
find(word)
click to toggle source
# File lib/jp_stations.rb, line 28 def self.find(word) return if word.nil? obj_station = search(word) obj_station.map { |station| build(station) } end
search(word)
click to toggle source
# File lib/jp_stations.rb, line 35 def self.search(word) data.select do |station| station[:kana].include?(word) || station[:kanji].include?(word) end end