Class: Compo::Branches::Constant

Inherits:
Leaf show all
Defined in:
lib/compo/branches/constant.rb

Overview

A Leaf containing a constant value

The value can be retrieved using #value.

Instance Attribute Summary collapse

Attributes included from Mixins::ParentTracker

#parent

Instance Method Summary collapse

Methods included from Branch

#find_url

Methods included from Mixins::UrlReferenceable

#parent, #url

Methods included from Mixins::ParentTracker

#root?, #update_parent

Methods included from Mixins::Movable

#move_to

Methods inherited from Composites::Leaf

#children

Methods included from Composites::Composite

#add, #get_child, #get_child_such_that, #on_node, #remove, #remove_id

Constructor Details

#initialize(value) ⇒ Constant

Initialises the Constant

Examples:

Initialising a Constant with a given value.

Constant.new(:value)

Parameters:

  • value (Object)

    The value of the constant.



17
18
19
20
# File 'lib/compo/branches/constant.rb', line 17

def initialize(value)
  super()
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the current value of this Constant

Examples:

Retrieving a Constant’s value.

const = Constant.new(:spoon)
const.value
#=> :spoon

Returns:

  • (Object)

    The Constant’s internal value.



31
32
33
# File 'lib/compo/branches/constant.rb', line 31

def value
  @value
end