Class: SearchApi::YouTubeSearchOptions

Inherits:
Object
  • Object
show all
Includes:
DynamicSchema::Definable, Helpers
Defined in:
lib/searchapi/youtube_search_options.rb

Constant Summary collapse

COUNTRIES =
%w[
  DZ AR AU AT AZ BH BD BY BE BO BA BR BG KH CA
  CL CO CR HR CY CZ DK DO EC EG SV EE FI FR GE
  DE GH GR GT HN HK HU IS IN ID IQ IE IL IT JM
  JP JO KZ KE KW LA LV LB LY LI LT LU MY MT MX
  ME MA NP NL NZ NI NG MK NO OM PK PA PG PY PE
  PH PL PT PR QA RO RU SA SN RS SG SK SI ZA KR
  ES LK SE CH TW TZ TH TN TR UG UA AE GB US UY
  VE VN YE ZW
]
LANGUAGES =
%w[
  af az id ms bs ca cs da de et en-in en-gb en
  es es-419 es-us eu fil fr fr-ca gl hr zu is
  it sw lv lt hu nl no uz pl pt-pt pt ro sq sk
  sl sr-latn fi sv vi tr be bg ky kk mk mn ru
  sr uk el hy iw ur ar fa ne mr hi as bn pa gu
  or ta te kn ml si th lo my ka am km zh-cn
  zh-tw zh-hk ja ko
]
NORMALIZE_UPCASE =
->(v) { v.to_s.upcase }
NORMALIZE_DOWNCASE =
->(v) { v.to_s.downcase }

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#string_camelize

Constructor Details

#initialize(options = {}, api_options: nil) ⇒ YouTubeSearchOptions

Returns a new instance of YouTubeSearchOptions.



50
51
52
53
# File 'lib/searchapi/youtube_search_options.rb', line 50

def initialize( options = {}, api_options: nil )
  @options = self.class.builder.build( options || {} )
  @options = api_options.merge( @options ) if api_options
end

Class Method Details

.build(options = nil, &block) ⇒ Object



42
43
44
# File 'lib/searchapi/youtube_search_options.rb', line 42

def self.build( options = nil, &block )
  new( api_options: builder.build( options, &block ) )
end

.build!(options = nil, &block) ⇒ Object



46
47
48
# File 'lib/searchapi/youtube_search_options.rb', line 46

def self.build!( options = nil, &block )
  new( api_options: builder.build!( options, &block ) )
end

Instance Method Details

#to_hObject



55
56
57
58
59
# File 'lib/searchapi/youtube_search_options.rb', line 55

def to_h
  result = @options.to_h
  result[ :engine ] = 'youtube'
  result
end