Class: Elibri::ONIX::Dict::Release_3_0::Base
- Inherits:
-
Object
- Object
- Elibri::ONIX::Dict::Release_3_0::Base
- Defined in:
- lib/elibri_onix_dict/onix_3_0/base.rb
Overview
Klasa podstawowa dla wszystkich słowników ONIX`a
Instance Attribute Summary collapse
-
#const_name ⇒ Object
readonly
Returns the value of attribute const_name.
-
#name(locale = :pl) ⇒ Object
readonly
ruby-1.9.2-head > dict_item.name(:en) => “author”.
-
#onix_code ⇒ Object
readonly
Returns the value of attribute onix_code.
-
#onix_doc ⇒ Object
readonly
Returns the value of attribute onix_doc.
Class Method Summary collapse
- .all ⇒ Object
-
.all_except(*onix_codes) ⇒ Object
Zwróć listę wszystkich elementów słownika, poza tymi o kodach przekazanych jako argument.
-
.by_const_names(const_names) ⇒ Object
zwróć wszyskie wartości o określonych const_names.
- .find_by_onix_code(searched_onix_code) ⇒ Object
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/elibri_onix_dict/onix_3_0/base.rb', line 30 def method_missing(method_name, *args) if args.empty? if method_name.to_s =~ /\?$/ mn = method_name.to_s.gsub("?", "") if instance_variable_defined?("@#{mn}") value = instance_variable_get("@#{mn}") if value.is_a?(TrueClass) || value.is_a?(FalseClass) return value end end elsif instance_variable_defined?("@#{method_name}") return instance_variable_get("@#{method_name}") end end super end |
Instance Attribute Details
#const_name ⇒ Object (readonly)
Returns the value of attribute const_name.
10 11 12 |
# File 'lib/elibri_onix_dict/onix_3_0/base.rb', line 10 def const_name @const_name end |
#name(locale = :pl) ⇒ Object (readonly)
ruby-1.9.2-head > dict_item.name(:en)
=> "author"
14 15 16 |
# File 'lib/elibri_onix_dict/onix_3_0/base.rb', line 14 def name @name end |
#onix_code ⇒ Object (readonly)
Returns the value of attribute onix_code.
10 11 12 |
# File 'lib/elibri_onix_dict/onix_3_0/base.rb', line 10 def onix_code @onix_code end |
#onix_doc ⇒ Object (readonly)
Returns the value of attribute onix_doc.
10 11 12 |
# File 'lib/elibri_onix_dict/onix_3_0/base.rb', line 10 def onix_doc @onix_doc end |
Class Method Details
.all ⇒ Object
52 53 54 |
# File 'lib/elibri_onix_dict/onix_3_0/base.rb', line 52 def self.all self.const_get(:ALL) # Wartość stałej 'ALL' pobierz dynamicznie - z klasy pochodnej... end |
.all_except(*onix_codes) ⇒ Object
Zwróć listę wszystkich elementów słownika, poza tymi o kodach przekazanych jako argument
62 63 64 65 |
# File 'lib/elibri_onix_dict/onix_3_0/base.rb', line 62 def self.all_except(*onix_codes) onix_codes.flatten! self.all.reject {|dict_item| onix_codes.include?(dict_item.onix_code) } end |
.by_const_names(const_names) ⇒ Object
zwróć wszyskie wartości o określonych const_names
57 58 59 |
# File 'lib/elibri_onix_dict/onix_3_0/base.rb', line 57 def self.by_const_names(const_names) self.all.find_all { |value| const_names.include?(value.const_name) } end |
.find_by_onix_code(searched_onix_code) ⇒ Object
47 48 49 |
# File 'lib/elibri_onix_dict/onix_3_0/base.rb', line 47 def self.find_by_onix_code(searched_onix_code) self.all.find {|dict_item| dict_item.onix_code == searched_onix_code } end |
Instance Method Details
#onix_doc? ⇒ Boolean
26 27 28 |
# File 'lib/elibri_onix_dict/onix_3_0/base.rb', line 26 def onix_doc? onix_doc end |