Class: Contentful::TaxonomyConceptScheme
- Inherits:
-
BaseResource
- Object
- BaseResource
- Contentful::TaxonomyConceptScheme
- Defined in:
- lib/contentful/taxonomy_concept_scheme.rb
Overview
Resource class for TaxonomyConceptScheme.
Instance Attribute Summary collapse
-
#concepts ⇒ Object
readonly
Returns the value of attribute concepts.
-
#top_concepts ⇒ Object
readonly
Returns the value of attribute top_concepts.
-
#total_concepts ⇒ Object
readonly
Returns the value of attribute total_concepts.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Attributes inherited from BaseResource
#_metadata, #default_locale, #raw, #sys
Instance Method Summary collapse
-
#asset? ⇒ Boolean
Returns false for resources that are not assets.
- #definition(locale = nil) ⇒ Object
-
#entry? ⇒ Boolean
Returns false for resources that are not entries.
-
#initialize(item) ⇒ TaxonomyConceptScheme
constructor
A new instance of TaxonomyConceptScheme.
-
#pref_label(locale = nil) ⇒ Object
Access localized fields.
-
#taxonomy_concept? ⇒ Boolean
Returns false for resources that are not taxonomy concepts.
-
#taxonomy_concept_scheme? ⇒ Boolean
Returns true for resources that are taxonomy concept schemes.
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
#concepts ⇒ Object (readonly)
Returns the value of attribute concepts.
7 8 9 |
# File 'lib/contentful/taxonomy_concept_scheme.rb', line 7 def concepts @concepts end |
#top_concepts ⇒ Object (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_concepts ⇒ Object (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 |
#uri ⇒ Object (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
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
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
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
19 20 21 |
# File 'lib/contentful/taxonomy_concept_scheme.rb', line 19 def taxonomy_concept_scheme? true end |