Class: Net::DND::Field
- Inherits:
-
Object
- Object
- Net::DND::Field
- 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
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#readable ⇒ Object
readonly
Returns the value of attribute readable.
-
#writeable ⇒ Object
readonly
Returns the value of attribute writeable.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, writeable, readable) ⇒ Field
constructor
A new instance of Field.
- #inspect ⇒ Object
- #read_all? ⇒ Boolean
- #to_s ⇒ Object
- #to_sym ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/net/dnd/field.rb', line 20 def name @name end |
#readable ⇒ Object (readonly)
Returns the value of attribute readable.
20 21 22 |
# File 'lib/net/dnd/field.rb', line 20 def readable @readable end |
#writeable ⇒ Object (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
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
#inspect ⇒ Object
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
46 47 48 |
# File 'lib/net/dnd/field.rb', line 46 def read_all? @readable == 'A' end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/net/dnd/field.rb', line 38 def to_s @name end |
#to_sym ⇒ Object
42 43 44 |
# File 'lib/net/dnd/field.rb', line 42 def to_sym @name.to_sym end |