Class: Fleakr::Api::TagOption

Inherits:
SimpleOption show all
Defined in:
lib/fleakr/api/option.rb

Overview

TagOption

Represents values for tags

Instance Attribute Summary

Attributes inherited from SimpleOption

#type, #value

Instance Method Summary collapse

Constructor Details

#initialize(type, value) ⇒ TagOption

Tag with specified values. Value passed will be converted to an array if it isn’t already



63
64
65
66
# File 'lib/fleakr/api/option.rb', line 63

def initialize(type, value)
  super type, value
  @value = Array(self.value)
end

Instance Method Details

#to_hashObject

Hash representation of tag values (separated by spaces). Handles multi-word tags by enclosing each tag in double quotes.



71
72
73
74
# File 'lib/fleakr/api/option.rb', line 71

def to_hash
  tags = value.map {|tag| "\"#{tag}\"" }
  {type => tags.join(' ')}
end