Class: Episodic::Platform::CustomFieldItem

Inherits:
Item
  • Object
show all
Defined in:
lib/episodic/platform/query_methods.rb

Overview

Represents a custom field element returned from an episodes or playlists request.

Instance Method Summary collapse

Methods inherited from Item

#exists?, #id, #initialize, #method_missing, #players, #respond_to?, #thumbnails

Constructor Details

This class inherits a constructor from Episodic::Platform::Item

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Episodic::Platform::Item

Instance Method Details

#boolean_fieldsObject

Provides a list of fields that are actually dates.

Returns

Array

A list of field names as symbols.



715
716
717
# File 'lib/episodic/platform/query_methods.rb', line 715

def boolean_fields
  return [:required]
end

#integer_fieldsObject

Provides a list of fields that are actually integers.

Returns

Array

A list of field names as symbols.



704
705
706
# File 'lib/episodic/platform/query_methods.rb', line 704

def integer_fields
  return [:position]
end

#typeObject

Explicitly declare to avoid warning: Object#type is deprecated; use Object#class.



693
694
695
# File 'lib/episodic/platform/query_methods.rb', line 693

def type
  return @item["type"]
end

#valuesObject

Get the values for this field. Values are always returned as strings except when the type is external_select then it is an array or two element arrays with the external id and external value respectively.

Returns

Array

In most cases this will be a single element array.



670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
# File 'lib/episodic/platform/query_methods.rb', line 670

def values
  
  if (@values.nil?)
    @values = []
    _values = @item["value"]  
    unless (_values.is_a?(Array))
      _values = [_values]
    end
    _values.compact.each do |v|
      if (v.is_a?(Hash))
        @values << [v["id"].strip, v["content"].strip]
      else
        @values << v.strip
      end
    end
  end
  
  return @values
end