Class: Cts::Mpx::Field

Inherits:
Object
  • Object
show all
Includes:
Creatable
Defined in:
lib/cts/mpx/field.rb

Overview

Indivudal field, contains the name, value, and an optional namespace

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#name name of the field(nameofthefield) ⇒ String

Returns:

  • (String)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cts/mpx/field.rb', line 10

class Field
  include Creatable

  attribute name: 'name', kind_of: String
  attribute name: 'value'
  attribute(name: 'xmlns', kind_of: Hash) { |o, xmlns| o.xmlns = xmlns if o.custom? }

  # Return just the name value as key/value
  # @return [Hash]
  def to_h
    { name => value }
  end

  # Determines if this field is a custom field or not
  # @return [Symbol] true if it is a custom field
  def custom?
    return true if name.include? "$"

    false
  end

  # Set the namespace of the field
  # @param [Hash] xmlns namespace of the fields
  # @return [Void]
  def xmlns=(xmlns)
    @xmlns = xmlns if name.include? '$'
  end
end

#value value of the field(valueofthefield) ⇒ Object

Returns:

  • (Object)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cts/mpx/field.rb', line 10

class Field
  include Creatable

  attribute name: 'name', kind_of: String
  attribute name: 'value'
  attribute(name: 'xmlns', kind_of: Hash) { |o, xmlns| o.xmlns = xmlns if o.custom? }

  # Return just the name value as key/value
  # @return [Hash]
  def to_h
    { name => value }
  end

  # Determines if this field is a custom field or not
  # @return [Symbol] true if it is a custom field
  def custom?
    return true if name.include? "$"

    false
  end

  # Set the namespace of the field
  # @param [Hash] xmlns namespace of the fields
  # @return [Void]
  def xmlns=(xmlns)
    @xmlns = xmlns if name.include? '$'
  end
end

#xmlns namespace of the field(namespaceofthefield) ⇒ Hash

Returns:

  • (Hash)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cts/mpx/field.rb', line 10

class Field
  include Creatable

  attribute name: 'name', kind_of: String
  attribute name: 'value'
  attribute(name: 'xmlns', kind_of: Hash) { |o, xmlns| o.xmlns = xmlns if o.custom? }

  # Return just the name value as key/value
  # @return [Hash]
  def to_h
    { name => value }
  end

  # Determines if this field is a custom field or not
  # @return [Symbol] true if it is a custom field
  def custom?
    return true if name.include? "$"

    false
  end

  # Set the namespace of the field
  # @param [Hash] xmlns namespace of the fields
  # @return [Void]
  def xmlns=(xmlns)
    @xmlns = xmlns if name.include? '$'
  end
end

Instance Method Details

#custom?Symbol

Determines if this field is a custom field or not

Returns:

  • (Symbol)

    true if it is a custom field



25
26
27
28
29
# File 'lib/cts/mpx/field.rb', line 25

def custom?
  return true if name.include? "$"

  false
end

#to_hHash

Return just the name value as key/value

Returns:

  • (Hash)


19
20
21
# File 'lib/cts/mpx/field.rb', line 19

def to_h
  { name => value }
end

#xmlns=(xmlns) ⇒ Void

Set the namespace of the field

Parameters:

  • xmlns (Hash)

    namespace of the fields

Returns:

  • (Void)


34
35
36
# File 'lib/cts/mpx/field.rb', line 34

def xmlns=(xmlns)
  @xmlns = xmlns if name.include? '$'
end