class Blather::Stanza::X::Field::Option

Option stanza fragment

Public Class Methods

new(value, label = nil) click to toggle source

Create a new X Field Option @overload new(node)

Imports the XML::Node to create a Field option object
@param [XML::Node] node the node object to import

@overload new(opts = {})

Creates a new Field option using a hash of options
@param [Hash] opts a hash of options
@option opts [String] :value the value of the field option
@option opts [String] :label the human readable label for the field option

@overload new(value, label = nil)

Create a new Field option by name
@param [String] value the value of the field option
@param [String, nil] label the human readable label for the field option
Calls superclass method
# File lib/blather/stanza/x.rb, line 363
def self.new(value, label = nil)
  new_node = super :option

  case value
  when Nokogiri::XML::Node
    new_node.inherit value
  when Hash
    new_node.value = value[:value]
    new_node.label = value[:label]
  else
    new_node.value = value
    new_node.label = label
  end
  new_node
end

Public Instance Methods

label() click to toggle source

The Field Option's label @return [String]

# File lib/blather/stanza/x.rb, line 402
def label
  read_attr :label
end
label=(label) click to toggle source

Set the Field Option's label @param [String] label the new label for the field option

# File lib/blather/stanza/x.rb, line 408
def label=(label)
  write_attr :label, label
end
value() click to toggle source

The Field Option's value @return [String]

# File lib/blather/stanza/x.rb, line 381
def value
  if self.namespace
    content_from 'ns:value', :ns => self.namespace.href
  else
    content_from :value
  end
end
value=(value) click to toggle source

Set the Field Option's value @param [String] value the new value for the field option

# File lib/blather/stanza/x.rb, line 391
def value=(value)
  self.remove_children :value
  if value
    self << (v = XMPPNode.new(:value))
    v.namespace = self.namespace
    v << value
  end
end