Class: Gcloud::Search::FieldValue

Inherits:
Object
  • Object
show all
Defined in:
lib/gcloud/search/field_value.rb

Overview

FieldValue

FieldValue is used to represent a value that belongs to a field. (See Fields and FieldValues)

A field value must have a type. A value that is a Numeric will default to :number, while a DateTime will default to :datetime. If a type is not provided it will be determined by looking at the value.

String values (text, html, atom) can also specify a lang value, which is an ISO 639-1 code.

Examples:

require "gcloud"

gcloud = Gcloud.new
search = gcloud.search
index = search.index "products"

document = index.document "product-sku-000001"
puts "The document description is:"
document["description"].each do |value|
  puts "* #{value} (#{value.type}) [#{value.lang}]"
end

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#langObject (readonly)

Returns the value of attribute lang


49
50
51
# File 'lib/gcloud/search/field_value.rb', line 49

def lang
  @lang
end

#nameObject (readonly)

Returns the value of attribute name


49
50
51
# File 'lib/gcloud/search/field_value.rb', line 49

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type


49
50
51
# File 'lib/gcloud/search/field_value.rb', line 49

def type
  @type
end

Instance Method Details

#string_type?Boolean

Determines if the value a string type. The value is text or html or atom (or default).

Returns:

  • (Boolean)

96
97
98
# File 'lib/gcloud/search/field_value.rb', line 96

def string_type?
  [:atom, :default, :html, :text].include? type
end