Class: Contentful::TaxonomyConcept

Inherits:
BaseResource show all
Defined in:
lib/contentful/taxonomy_concept.rb

Overview

Resource class for TaxonomyConcept.

See Also:

  • https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/taxonomy/concept

Instance Attribute Summary collapse

Attributes inherited from BaseResource

#_metadata, #default_locale, #raw, #sys

Instance Method Summary collapse

Methods inherited from BaseResource

#==, #inspect, #marshal_dump, #marshal_load, #reload

Constructor Details

#initialize(item) ⇒ TaxonomyConcept

Returns a new instance of TaxonomyConcept.



9
10
11
12
13
14
15
16
17
# File 'lib/contentful/taxonomy_concept.rb', line 9

def initialize(item, *)
  super

  @uri = item.fetch('uri', nil)
  @notations = item.fetch('notations', [])
  @broader = item.fetch('broader', [])
  @related = item.fetch('related', [])
  @concept_schemes = item.fetch('conceptSchemes', [])
end

Instance Attribute Details

#broaderObject (readonly)

Returns the value of attribute broader.



7
8
9
# File 'lib/contentful/taxonomy_concept.rb', line 7

def broader
  @broader
end

#concept_schemesObject (readonly)

Returns the value of attribute concept_schemes.



7
8
9
# File 'lib/contentful/taxonomy_concept.rb', line 7

def concept_schemes
  @concept_schemes
end

#notationsObject (readonly)

Returns the value of attribute notations.



7
8
9
# File 'lib/contentful/taxonomy_concept.rb', line 7

def notations
  @notations
end

Returns the value of attribute related.



7
8
9
# File 'lib/contentful/taxonomy_concept.rb', line 7

def related
  @related
end

#uriObject (readonly)

Returns the value of attribute uri.



7
8
9
# File 'lib/contentful/taxonomy_concept.rb', line 7

def uri
  @uri
end

Instance Method Details

#alt_labels(locale = nil) ⇒ Object



41
42
43
44
45
# File 'lib/contentful/taxonomy_concept.rb', line 41

def alt_labels(locale = nil)
  locale ||= default_locale
  alt_labels = raw.fetch('altLabels', {})
  alt_labels.is_a?(Hash) ? alt_labels.fetch(locale.to_s, []) : alt_labels
end

#asset?Boolean

Returns false for resources that are not assets

Returns:

  • (Boolean)


30
31
32
# File 'lib/contentful/taxonomy_concept.rb', line 30

def asset?
  false
end

#change_note(locale = nil) ⇒ Object



59
60
61
62
63
# File 'lib/contentful/taxonomy_concept.rb', line 59

def change_note(locale = nil)
  locale ||= default_locale
  change_note = raw.fetch('changeNote', {})
  change_note.is_a?(Hash) ? change_note.fetch(locale.to_s, '') : change_note
end

#definition(locale = nil) ⇒ Object



65
66
67
68
69
# File 'lib/contentful/taxonomy_concept.rb', line 65

def definition(locale = nil)
  locale ||= default_locale
  definition = raw.fetch('definition', {})
  definition.is_a?(Hash) ? definition.fetch(locale.to_s, '') : definition
end

#editorial_note(locale = nil) ⇒ Object



71
72
73
74
75
# File 'lib/contentful/taxonomy_concept.rb', line 71

def editorial_note(locale = nil)
  locale ||= default_locale
  editorial_note = raw.fetch('editorialNote', {})
  editorial_note.is_a?(Hash) ? editorial_note.fetch(locale.to_s, '') : editorial_note
end

#entry?Boolean

Returns false for resources that are not entries

Returns:

  • (Boolean)


25
26
27
# File 'lib/contentful/taxonomy_concept.rb', line 25

def entry?
  false
end

#example(locale = nil) ⇒ Object



77
78
79
80
81
# File 'lib/contentful/taxonomy_concept.rb', line 77

def example(locale = nil)
  locale ||= default_locale
  example = raw.fetch('example', {})
  example.is_a?(Hash) ? example.fetch(locale.to_s, '') : example
end

#hidden_labels(locale = nil) ⇒ Object



47
48
49
50
51
# File 'lib/contentful/taxonomy_concept.rb', line 47

def hidden_labels(locale = nil)
  locale ||= default_locale
  hidden_labels = raw.fetch('hiddenLabels', {})
  hidden_labels.is_a?(Hash) ? hidden_labels.fetch(locale.to_s, []) : hidden_labels
end

#history_note(locale = nil) ⇒ Object



83
84
85
86
87
# File 'lib/contentful/taxonomy_concept.rb', line 83

def history_note(locale = nil)
  locale ||= default_locale
  history_note = raw.fetch('historyNote', {})
  history_note.is_a?(Hash) ? history_note.fetch(locale.to_s, '') : history_note
end

#note(locale = nil) ⇒ Object



53
54
55
56
57
# File 'lib/contentful/taxonomy_concept.rb', line 53

def note(locale = nil)
  locale ||= default_locale
  note = raw.fetch('note', {})
  note.is_a?(Hash) ? note.fetch(locale.to_s, '') : note
end

#pref_label(locale = nil) ⇒ Object

Access localized fields



35
36
37
38
39
# File 'lib/contentful/taxonomy_concept.rb', line 35

def pref_label(locale = nil)
  locale ||= default_locale
  pref_label = raw.fetch('prefLabel', {})
  pref_label.is_a?(Hash) ? pref_label.fetch(locale.to_s, nil) : pref_label
end

#scope_note(locale = nil) ⇒ Object



89
90
91
92
93
# File 'lib/contentful/taxonomy_concept.rb', line 89

def scope_note(locale = nil)
  locale ||= default_locale
  scope_note = raw.fetch('scopeNote', {})
  scope_note.is_a?(Hash) ? scope_note.fetch(locale.to_s, '') : scope_note
end

#taxonomy_concept?Boolean

Returns true for resources that are taxonomy concepts

Returns:

  • (Boolean)


20
21
22
# File 'lib/contentful/taxonomy_concept.rb', line 20

def taxonomy_concept?
  true
end