Class: Journeyviz::Screen

Inherits:
Object
  • Object
show all
Includes:
NormalizedName
Defined in:
lib/journeyviz/screen.rb

Instance Attribute Summary collapse

Attributes included from NormalizedName

#name

Instance Method Summary collapse

Constructor Details

#initialize(name, scope = nil) ⇒ Screen

Returns a new instance of Screen.



13
14
15
16
17
# File 'lib/journeyviz/screen.rb', line 13

def initialize(name, scope = nil)
  assign_normalize_name(name)
  @actions = []
  assign_scope(scope)
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



11
12
13
# File 'lib/journeyviz/screen.rb', line 11

def actions
  @actions
end

#scopeObject (readonly)

Returns the value of attribute scope.



11
12
13
# File 'lib/journeyviz/screen.rb', line 11

def scope
  @scope
end

Instance Method Details

#action(name, **params) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/journeyviz/screen.rb', line 19

def action(name, **params)
  action = Action.new(name, self, **params)

  if actions.any? { |defined_action| action.name == defined_action.name }
    raise DuplicatedDefinition, "Duplicated action name: #{name}"
  end

  @actions << action
end