Class: BlocklyInterpreter::ProgramCache
- Inherits:
-
Object
- Object
- BlocklyInterpreter::ProgramCache
- Includes:
- MonitorMixin
- Defined in:
- lib/blockly_interpreter/program_cache.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(parser) ⇒ ProgramCache
constructor
A new instance of ProgramCache.
- #load_program(xml) ⇒ Object
Constructor Details
#initialize(parser) ⇒ ProgramCache
Returns a new instance of ProgramCache.
8 9 10 11 12 |
# File 'lib/blockly_interpreter/program_cache.rb', line 8 def initialize(parser) @parser = parser @cache = {} super() end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
6 7 8 |
# File 'lib/blockly_interpreter/program_cache.rb', line 6 def parser @parser end |
Instance Method Details
#load_program(xml) ⇒ Object
14 15 16 17 18 |
# File 'lib/blockly_interpreter/program_cache.rb', line 14 def load_program(xml) synchronize do @cache[Digest::SHA1.hexdigest(xml || '')] ||= @parser.parse(xml) end end |