class NHKore::Entry
@author Jonathan Bradley Whited @since 0.2.0
Constants
- HYOUKI_SEP
Attributes
defns[R]
id[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/nhkore/entry.rb, line 27 def initialize super() @defns = [] @id = nil end
scrape(id,array,missingno: nil,url: nil)
click to toggle source
# File lib/nhkore/entry.rb, line 63 def self.scrape(id,array,missingno: nil,url: nil) entry = Entry.new entry.id = Util.unspace_web_str(id.to_s).downcase return nil if entry.id.empty? array.each do |hash| defn = Defn.scrape(hash,missingno: missingno,url: url) entry.defns << defn unless defn.nil? end return nil if entry.defns.empty? return entry end
Public Instance Methods
build_defn()
click to toggle source
# File lib/nhkore/entry.rb, line 34 def build_defn defns = [] i = 0 @defns.each do |defn| defns << "#{i += 1})#{defn}" # Japanese parenthesis end return defns.join("\n") end
build_hyouki()
click to toggle source
# File lib/nhkore/entry.rb, line 45 def build_hyouki # Since Ruby v1.9, Hash preserves order. # Ruby v2.7 doc for Set still says no guarantee of order, so don't use. hyoukis = {} @defns.each do |defn| defn.hyoukis.each do |hyouki| hyouki = hyouki.chomp(HYOUKI_SEP) next if hyouki.empty? hyoukis[hyouki] = true end end return hyoukis.keys.join(HYOUKI_SEP) end
to_s()
click to toggle source
# File lib/nhkore/entry.rb, line 79 def to_s s = ''.dup return s if @defns.empty? hyouki = build_hyouki s << "#{hyouki}\n" unless Util.empty_web_str?(hyouki) s << build_defn return s end