Class: LambdaGem::Dictionary
- Inherits:
-
Object
- Object
- LambdaGem::Dictionary
- Defined in:
- lib/dictionary.rb
Instance Attribute Summary collapse
-
#operator_priority ⇒ Object
readonly
Returns the value of attribute operator_priority.
Instance Method Summary collapse
- #[](operator) ⇒ Object
- #add_operator(symbol, block, priority) ⇒ Object
- #contains?(operator) ⇒ Boolean
- #count ⇒ Object
-
#initialize(dict = nil) ⇒ Dictionary
constructor
A new instance of Dictionary.
Constructor Details
#initialize(dict = nil) ⇒ Dictionary
Returns a new instance of Dictionary.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dictionary.rb', line 9 def initialize dict=nil if dict.nil? @operator_dict, @operator_priority = Hash.new, Hash.new @operator_priority.default(-1) populate_default_dict populate_default_priorities else @operator_dict = dict end end |
Instance Attribute Details
#operator_priority ⇒ Object (readonly)
Returns the value of attribute operator_priority.
7 8 9 |
# File 'lib/dictionary.rb', line 7 def operator_priority @operator_priority end |
Instance Method Details
#[](operator) ⇒ Object
24 25 26 |
# File 'lib/dictionary.rb', line 24 def [] operator @operator_dict[operator] end |
#add_operator(symbol, block, priority) ⇒ Object
32 33 34 35 |
# File 'lib/dictionary.rb', line 32 def add_operator symbol, block, priority @operator_dict[symbol] = block @operator_priority[symbol] = priority end |
#contains?(operator) ⇒ Boolean
28 29 30 |
# File 'lib/dictionary.rb', line 28 def contains? operator @operator_dict.include? operator end |
#count ⇒ Object
20 21 22 |
# File 'lib/dictionary.rb', line 20 def count @operator_dict.count end |