Class: DraftjsExporter::EntityState
- Inherits:
-
Object
- Object
- DraftjsExporter::EntityState
- Defined in:
- lib/draftjs_exporter/entity_state.rb
Instance Attribute Summary collapse
-
#entity_decorators ⇒ Object
readonly
Returns the value of attribute entity_decorators.
-
#entity_map ⇒ Object
readonly
Returns the value of attribute entity_map.
-
#entity_stack ⇒ Object
readonly
Returns the value of attribute entity_stack.
-
#root_element ⇒ Object
readonly
Returns the value of attribute root_element.
Instance Method Summary collapse
- #apply(command) ⇒ Object
- #current_parent ⇒ Object
-
#initialize(root_element, entity_decorators, entity_map) ⇒ EntityState
constructor
A new instance of EntityState.
Constructor Details
#initialize(root_element, entity_decorators, entity_map) ⇒ EntityState
Returns a new instance of EntityState.
8 9 10 11 12 |
# File 'lib/draftjs_exporter/entity_state.rb', line 8 def initialize(root_element, entity_decorators, entity_map) @entity_decorators = entity_decorators @entity_map = entity_map @entity_stack = [[Entities::Null.new.call(root_element, nil), nil]] end |
Instance Attribute Details
#entity_decorators ⇒ Object (readonly)
Returns the value of attribute entity_decorators.
6 7 8 |
# File 'lib/draftjs_exporter/entity_state.rb', line 6 def entity_decorators @entity_decorators end |
#entity_map ⇒ Object (readonly)
Returns the value of attribute entity_map.
6 7 8 |
# File 'lib/draftjs_exporter/entity_state.rb', line 6 def entity_map @entity_map end |
#entity_stack ⇒ Object (readonly)
Returns the value of attribute entity_stack.
6 7 8 |
# File 'lib/draftjs_exporter/entity_state.rb', line 6 def entity_stack @entity_stack end |
#root_element ⇒ Object (readonly)
Returns the value of attribute root_element.
6 7 8 |
# File 'lib/draftjs_exporter/entity_state.rb', line 6 def root_element @root_element end |
Instance Method Details
#apply(command) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/draftjs_exporter/entity_state.rb', line 14 def apply(command) case command.name when :start_entity start_command(command) when :stop_entity stop_command(command) end end |
#current_parent ⇒ Object
23 24 25 26 |
# File 'lib/draftjs_exporter/entity_state.rb', line 23 def current_parent element, _data = entity_stack.last element end |