Class: Net::DND::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/net/dnd/field.rb

Overview

This class comes into play, because when the DND.start method is used, you pass in a list of fields that you want to have returned. That list is first verified against the host DND server’s known list of fields, through use of the protocol’s FIELDS command. When sent with a list of fields, the server responds back with each fields read and write permissions. This data, along with the fields name is captured and stored in instances of this class.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, writeable, readable) ⇒ Field

Returns a new instance of Field.



22
23
24
25
26
# File 'lib/net/dnd/field.rb', line 22

def initialize(name, writeable, readable)
  @name = name.to_s
  store_access_value(:writeable, writeable)
  store_access_value(:readable, readable)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



20
21
22
# File 'lib/net/dnd/field.rb', line 20

def name
  @name
end

#readableObject (readonly)

Returns the value of attribute readable.



20
21
22
# File 'lib/net/dnd/field.rb', line 20

def readable
  @readable
end

#writeableObject (readonly)

Returns the value of attribute writeable.



20
21
22
# File 'lib/net/dnd/field.rb', line 20

def writeable
  @writeable
end

Class Method Details

.from_field_line(line) ⇒ Object

Raises:



28
29
30
31
32
# File 'lib/net/dnd/field.rb', line 28

def self.from_field_line(line)
  args = line.split
  raise FieldLineInvalid unless args.length == 3
  new(args[0], args[1], args[2])
end

Instance Method Details

#inspectObject



34
35
36
# File 'lib/net/dnd/field.rb', line 34

def inspect
  "#<#{self.class} name=\"#{@name}\" writeable=\"#{@writeable}\" readable=\"#{@readable}\">"
end

#read_all?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/net/dnd/field.rb', line 46

def read_all?
  @readable == 'A'
end

#to_sObject



38
39
40
# File 'lib/net/dnd/field.rb', line 38

def to_s
  @name
end

#to_symObject



42
43
44
# File 'lib/net/dnd/field.rb', line 42

def to_sym
  @name.to_sym
end