class Pripara::Base
Attributes
attributes[R]
Public Class Methods
all()
click to toggle source
# File lib/ruripara/base.rb, line 14 def all config.map { |attributes| new(attributes) } end
find_by(attributes)
click to toggle source
# File lib/ruripara/base.rb, line 18 def find_by(attributes) raise ArgumentError unless (attributes.keys - attr_keys).empty? all.find { |obj| obj.match?(attributes) } end
new(attributes)
click to toggle source
# File lib/ruripara/base.rb, line 5 def initialize(attributes) @attributes = attributes.map { |k, v| [k.to_sym, v] }.to_h end
Private Class Methods
attr_keys()
click to toggle source
# File lib/ruripara/base.rb, line 37 def attr_keys raise NotImplementedError end
config()
click to toggle source
# File lib/ruripara/base.rb, line 25 def config @config ||= YAML.load_file(config_file_path) end
config_file_name()
click to toggle source
# File lib/ruripara/base.rb, line 33 def config_file_name raise NotImplementedError end
config_file_path()
click to toggle source
# File lib/ruripara/base.rb, line 29 def config_file_path File.join(File.dirname(__FILE__), "../../config/", config_file_name) end
Public Instance Methods
match?(attrs)
click to toggle source
# File lib/ruripara/base.rb, line 9 def match?(attrs) attrs.all? { |key, value| @attributes[key.to_sym] == value } end