Class: DraftjsExporter::EntityState

Inherits:
Object
  • Object
show all
Defined in:
lib/draftjs_exporter/entity_state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_element, entity_decorators, entity_map) ⇒ EntityState

Returns a new instance of EntityState.



11
12
13
14
15
# File 'lib/draftjs_exporter/entity_state.rb', line 11

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_decoratorsObject (readonly)

Returns the value of attribute entity_decorators.



9
10
11
# File 'lib/draftjs_exporter/entity_state.rb', line 9

def entity_decorators
  @entity_decorators
end

#entity_mapObject (readonly)

Returns the value of attribute entity_map.



9
10
11
# File 'lib/draftjs_exporter/entity_state.rb', line 9

def entity_map
  @entity_map
end

#entity_stackObject (readonly)

Returns the value of attribute entity_stack.



9
10
11
# File 'lib/draftjs_exporter/entity_state.rb', line 9

def entity_stack
  @entity_stack
end

#root_elementObject (readonly)

Returns the value of attribute root_element.



9
10
11
# File 'lib/draftjs_exporter/entity_state.rb', line 9

def root_element
  @root_element
end

Instance Method Details

#apply(command) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/draftjs_exporter/entity_state.rb', line 17

def apply(command)
  case command.name
  when :start_entity
    start_command(command)
  when :stop_entity
    stop_command(command)
  end
end

#current_parentObject



26
27
28
29
# File 'lib/draftjs_exporter/entity_state.rb', line 26

def current_parent
  element, _data = entity_stack.last
  element
end