class NHKore::SearchLinks

@author Jonathan Bradley Whited @since 0.2.0

Constants

DEFAULT_DIR
DEFAULT_FUTSUU_FILE
DEFAULT_FUTSUU_FILENAME
DEFAULT_YASASHII_FILE
DEFAULT_YASASHII_FILENAME

Attributes

Public Class Methods

build_file(filename) click to toggle source
# File lib/nhkore/search_link.rb, line 129
def self.build_file(filename)
  return File.join(DEFAULT_DIR,filename)
end
load_data(data,file: nil,**kargs) click to toggle source
# File lib/nhkore/search_link.rb, line 164
def self.load_data(data,file: nil,**kargs)
  data = Util.load_yaml(data,file: file)

  links = data[:links]

  slinks = SearchLinks.new

  links&.each() do |key,hash|
    key = key.to_s unless key.nil?
    slinks.links[key] = SearchLink.load_data(key,hash)
  end

  return slinks
end
new() click to toggle source
Calls superclass method
# File lib/nhkore/search_link.rb, line 138
def initialize
  super()

  @links = {}
end

Public Instance Methods

[](url) click to toggle source
# File lib/nhkore/search_link.rb, line 179
def [](url)
  url = url.url if url.respond_to?(:url)
  url = url.to_s unless url.nil?

  return @links[url]
end
each(&block) click to toggle source
# File lib/nhkore/search_link.rb, line 154
def each(&block)
  return @links.each(&block)
end
encode_with(coder) click to toggle source
# File lib/nhkore/search_link.rb, line 158
def encode_with(coder)
  # Order matters.

  coder[:links] = @links
end
length() click to toggle source
# File lib/nhkore/search_link.rb, line 186
def length
  return @links.length
end
to_s() click to toggle source
# File lib/nhkore/search_link.rb, line 190
def to_s
  return Util.dump_yaml(self)
end