Class: XRBP::NodeStore::STObject
- Inherits:
-
Object
- Object
- XRBP::NodeStore::STObject
- Includes:
- Parser
- Defined in:
- lib/xrbp/nodestore/sle/st_object.rb
Overview
Seralized Type containing fields associated with ids
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Instance Method Summary collapse
- #account_id(field) ⇒ Object
- #amount(field) ⇒ Object
- #field(type, id) ⇒ Object
- #field?(id) ⇒ Boolean
- #flag?(flag) ⇒ Boolean
- #flags ⇒ Object
-
#initialize(args = {}) ⇒ STObject
constructor
A new instance of STObject.
Constructor Details
#initialize(args = {}) ⇒ STObject
Returns a new instance of STObject.
12 13 14 15 16 17 |
# File 'lib/xrbp/nodestore/sle/st_object.rb', line 12 def initialize(args={}) @item = args[:item] @fields, remaining = parse_fields(item.data) raise unless remaining.size == 0 end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
10 11 12 |
# File 'lib/xrbp/nodestore/sle/st_object.rb', line 10 def fields @fields end |
#item ⇒ Object (readonly)
Returns the value of attribute item.
10 11 12 |
# File 'lib/xrbp/nodestore/sle/st_object.rb', line 10 def item @item end |
Instance Method Details
#account_id(field) ⇒ Object
41 42 43 |
# File 'lib/xrbp/nodestore/sle/st_object.rb', line 41 def account_id(field) field(STAccount, field) end |
#amount(field) ⇒ Object
37 38 39 |
# File 'lib/xrbp/nodestore/sle/st_object.rb', line 37 def amount(field) field(STAmount, field) end |
#field(type, id) ⇒ Object
32 33 34 35 |
# File 'lib/xrbp/nodestore/sle/st_object.rb', line 32 def field(type, id) fields[id] # type should already be converted in parsing process (TODO verify?) end |
#field?(id) ⇒ Boolean
28 29 30 |
# File 'lib/xrbp/nodestore/sle/st_object.rb', line 28 def field?(id) fields.key?(id) end |
#flag?(flag) ⇒ Boolean
23 24 25 26 |
# File 'lib/xrbp/nodestore/sle/st_object.rb', line 23 def flag?(flag) flag = NodeStore::Format::SERIALIZED_FLAGS[flag] if flag.is_a?(Symbol) flags & flag == flag end |
#flags ⇒ Object
19 20 21 |
# File 'lib/xrbp/nodestore/sle/st_object.rb', line 19 def flags @flags ||= fields[:flags] end |