Module: Rhom::RhomObject
- Included in:
- RhomSource, RhomSource
- Defined in:
- lib/rhom/rhom_object.rb
Constant Summary collapse
- @@reserved_names =
{"object" => "1", "source_id" => "1", "update_type" => "1", "attrib_type" => "1", "type" => "1", "set_notification" => "1", "clear_notification" => "1" }
Instance Method Summary collapse
-
#djb_hash(str, len) ⇒ Object
use djb hash function to generate temp object id.
- #extract_options(arr = []) ⇒ Object
- #method_name_reserved?(method) ⇒ Boolean
- #strip_braces(str = nil) ⇒ Object
Instance Method Details
#djb_hash(str, len) ⇒ Object
use djb hash function to generate temp object id
27 28 29 30 31 32 33 |
# File 'lib/rhom/rhom_object.rb', line 27 def djb_hash(str, len) hash = 5381 for i in (0..len) hash = ((hash << 5) + hash) + str[i].to_i end return hash end |
#extract_options(arr = []) ⇒ Object
35 36 37 |
# File 'lib/rhom/rhom_object.rb', line 35 def (arr=[]) arr.last.is_a?(Hash) ? arr.pop : {} end |
#method_name_reserved?(method) ⇒ Boolean
48 49 50 |
# File 'lib/rhom/rhom_object.rb', line 48 def method_name_reserved?(method) @@reserved_names.has_key?(method) end |
#strip_braces(str = nil) ⇒ Object
22 23 24 |
# File 'lib/rhom/rhom_object.rb', line 22 def strip_braces(str=nil) str ? str.gsub(/\{/,"").gsub(/\}/,"") : nil end |