Class: Elibri::ONIX::Release_3_0::Language

Inherits:
Object
  • Object
show all
Includes:
Inspector
Defined in:
lib/elibri_onix/onix_3_0/language.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inspector

#attribute_for_inspect, #inspect

Constructor Details

#initialize(data) ⇒ Language

Returns a new instance of Language.



20
21
22
23
24
# File 'lib/elibri_onix/onix_3_0/language.rb', line 20

def initialize(data)
  @to_xml = data.to_s
  @role = data.at_css('LanguageRole')&.text
  @code = data.at_css('LanguageCode')&.text
end

Instance Attribute Details

#codeObject (readonly)



15
16
17
# File 'lib/elibri_onix/onix_3_0/language.rb', line 15

def code
  @code
end

#roleObject (readonly)



11
12
13
# File 'lib/elibri_onix/onix_3_0/language.rb', line 11

def role
  @role
end

#to_xmlObject (readonly)

reprezentacja w xml



18
19
20
# File 'lib/elibri_onix/onix_3_0/language.rb', line 18

def to_xml
  @to_xml
end

Instance Method Details

#inspect_include_fieldsObject



38
39
40
# File 'lib/elibri_onix/onix_3_0/language.rb', line 38

def inspect_include_fields
   [:role_name, :language]
end

#languageObject

język, np. ‘polski’



32
33
34
35
36
# File 'lib/elibri_onix/onix_3_0/language.rb', line 32

def language
  Elibri::ONIX::Dict::Release_3_0::LanguageCode.find_by_onix_code(@code).name(:pl).downcase rescue nil
rescue

end

#role_nameObject

określenie roli jako string, np. language_of_text



27
28
29
# File 'lib/elibri_onix/onix_3_0/language.rb', line 27

def role_name
  Elibri::ONIX::Dict::Release_3_0::LanguageRole.find_by_onix_code(@role).const_name.downcase
end