Class: Contentful::TaxonomyConceptScheme

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

Overview

Resource class for TaxonomyConceptScheme.

See Also:

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

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) ⇒ TaxonomyConceptScheme

Returns a new instance of TaxonomyConceptScheme.



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

def initialize(item, *)
  super

  @uri = item.fetch('uri', nil)
  @top_concepts = item.fetch('topConcepts', [])
  @concepts = item.fetch('concepts', [])
  @total_concepts = item.fetch('totalConcepts', 0)
end

Instance Attribute Details

#conceptsObject (readonly)

Returns the value of attribute concepts.



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

def concepts
  @concepts
end

#top_conceptsObject (readonly)

Returns the value of attribute top_concepts.



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

def top_concepts
  @top_concepts
end

#total_conceptsObject (readonly)

Returns the value of attribute total_concepts.



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

def total_concepts
  @total_concepts
end

#uriObject (readonly)

Returns the value of attribute uri.



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

def uri
  @uri
end

Instance Method Details

#asset?Boolean

Returns false for resources that are not assets

Returns:

  • (Boolean)


34
35
36
# File 'lib/contentful/taxonomy_concept_scheme.rb', line 34

def asset?
  false
end

#definition(locale = nil) ⇒ Object



45
46
47
48
49
# File 'lib/contentful/taxonomy_concept_scheme.rb', line 45

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

#entry?Boolean

Returns false for resources that are not entries

Returns:

  • (Boolean)


29
30
31
# File 'lib/contentful/taxonomy_concept_scheme.rb', line 29

def entry?
  false
end

#pref_label(locale = nil) ⇒ Object

Access localized fields



39
40
41
42
43
# File 'lib/contentful/taxonomy_concept_scheme.rb', line 39

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

#taxonomy_concept?Boolean

Returns false for resources that are not taxonomy concepts

Returns:

  • (Boolean)


24
25
26
# File 'lib/contentful/taxonomy_concept_scheme.rb', line 24

def taxonomy_concept?
  false
end

#taxonomy_concept_scheme?Boolean

Returns true for resources that are taxonomy concept schemes

Returns:

  • (Boolean)


19
20
21
# File 'lib/contentful/taxonomy_concept_scheme.rb', line 19

def taxonomy_concept_scheme?
  true
end