Class: A2UI::Surface

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/a2ui/modules/surface.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Surface

Returns a new instance of Surface.



21
22
23
24
25
26
# File 'lib/a2ui/modules/surface.rb', line 21

def initialize(id)
  @id = id
  @root_id = T.let(nil, T.nilable(String))
  @components = T.let({}, T::Hash[String, Component])
  @data = T.let({}, T::Hash[String, T.untyped])
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



15
16
17
# File 'lib/a2ui/modules/surface.rb', line 15

def components
  @components
end

#dataObject (readonly)

Returns the value of attribute data.



18
19
20
# File 'lib/a2ui/modules/surface.rb', line 18

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/a2ui/modules/surface.rb', line 9

def id
  @id
end

#root_idObject (readonly)

Returns the value of attribute root_id.



12
13
14
# File 'lib/a2ui/modules/surface.rb', line 12

def root_id
  @root_id
end

Instance Method Details

#apply_data_updates(updates) ⇒ Object



35
36
37
38
39
# File 'lib/a2ui/modules/surface.rb', line 35

def apply_data_updates(updates)
  updates.each do |update|
    @data[update.path] = entries_to_hash(update.entries)
  end
end

#get_data(path) ⇒ Object



42
43
44
# File 'lib/a2ui/modules/surface.rb', line 42

def get_data(path)
  @data[path]
end

#set_components(root_id, components) ⇒ Object



29
30
31
32
# File 'lib/a2ui/modules/surface.rb', line 29

def set_components(root_id, components)
  @root_id = root_id
  components.each { |c| @components[c.id] = c }
end

#to_jsonObject



47
48
49
# File 'lib/a2ui/modules/surface.rb', line 47

def to_json
  @data.to_json
end