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

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

Constant Summary collapse

ATTRIBUTES =

:nodoc:

[
  :role, :code, :role_name, :language
]
RELATIONS =

:nodoc:

[
  :inspect_include_fields
]

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.



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

def initialize(data)
  @to_xml = data.to_s
  @role = data.at_xpath('xmlns:LanguageRole').try(:text)
  @code = data.at_xpath('xmlns:LanguageCode').try(:text)
end

Instance Attribute Details

#codeObject (readonly)



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

def code
  @code
end

#roleObject (readonly)



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

def role
  @role
end

#to_xmlObject (readonly)

reprezentacja w xml



35
36
37
# File 'lib/elibri_onix/onix_3_0/language.rb', line 35

def to_xml
  @to_xml
end

Instance Method Details

#eidObject



57
58
59
# File 'lib/elibri_onix/onix_3_0/language.rb', line 57

def eid
  "#{@role}-#{@code}"
end

#idObject



61
62
63
64
# File 'lib/elibri_onix/onix_3_0/language.rb', line 61

def id
  Kernel.warn "[DEPRECATION] `id` is deprecated. Please use `eid` instead."
  eid
end

#inspect_include_fieldsObject



53
54
55
# File 'lib/elibri_onix/onix_3_0/language.rb', line 53

def inspect_include_fields
   [:role_name, :language]
end

#languageObject

język, np. ‘polski’



49
50
51
# File 'lib/elibri_onix/onix_3_0/language.rb', line 49

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

#role_nameObject

określenie roli jako string, np. language_of_text



44
45
46
# File 'lib/elibri_onix/onix_3_0/language.rb', line 44

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