Class: GromNative::Node
- Inherits:
-
Object
- Object
- GromNative::Node
- Defined in:
- lib/grom_native/node.rb
Overview
A Ruby object populated with n-triple data.
Constant Summary collapse
- BLANK =
'blank_node'.freeze
Instance Attribute Summary collapse
-
#statements ⇒ Array
readonly
an array of n-triple statements.
Instance Method Summary collapse
-
#blank? ⇒ Boolean
Checks if Grom::Node is a blank node.
-
#initialize(statements, decorators = nil) ⇒ Node
constructor
A new instance of Node.
-
#method_missing(method, *params, &block) ⇒ Object
Allows the user to access instance variables as methods or raise an error if the variable is not defined.
-
#respond_to_missing?(method, include_all = false) ⇒ Boolean
node = Grom::Node.new(statements).
Constructor Details
#initialize(statements, decorators = nil) ⇒ Node
Returns a new instance of Node.
12 13 14 |
# File 'lib/grom_native/node.rb', line 12 def initialize(statements, decorators = nil) populate(statements, decorators) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *params, &block) ⇒ Object
Allows the user to access instance variables as methods or raise an error if the variable is not defined.
41 42 43 |
# File 'lib/grom_native/node.rb', line 41 def method_missing(method, *params, &block) instance_variable_get("@#{method}".to_sym) || super end |
Instance Attribute Details
#statements ⇒ Array (readonly)
an array of n-triple statements.
6 7 8 |
# File 'lib/grom_native/node.rb', line 6 def statements @statements end |
Instance Method Details
#blank? ⇒ Boolean
Checks if Grom::Node is a blank node
68 69 70 |
# File 'lib/grom_native/node.rb', line 68 def blank? @graph_id.match(%r(^_:)) end |
#respond_to_missing?(method, include_all = false) ⇒ Boolean
node = Grom::Node.new(statements)
node.respond_to?(:forename) #=> 'Jane'
node.respond_to?(:foo) #=> false
61 62 63 |
# File 'lib/grom_native/node.rb', line 61 def respond_to_missing?(method, include_all = false) instance_variable_get("@#{method}".to_sym) || super end |