Class: Annotable::Annotation

Inherits:
Object
  • Object
show all
Defined in:
lib/annotable/annotation.rb

Overview

Encapsulates annotation data: name, params & options.

my_annotation = Annotation.new(:name, ["some", "params"], {some: "options"})
my_annotation.name # => :name
my_annotation.params # => ["some", "params"]
my_annotation.options # => {some: "options"}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params = [], options = {}) ⇒ Annotation

Creates an new annotation.

Parameters:

  • name (Symbol)

    The annotation’s name

  • params (Array<Object>) (defaults to: [])

    The annotation’s params

  • options (Hash<Symbol, Object>) (defaults to: {})

    The annotation’s options



27
28
29
30
31
# File 'lib/annotable/annotation.rb', line 27

def initialize(name, params = [], options = {})
  @name = name
  @params = params
  @options = options
end

Instance Attribute Details

#nameSymbol (readonly)

Returns The annotation’s name.

Returns:

  • (Symbol)

    The annotation’s name



14
15
16
# File 'lib/annotable/annotation.rb', line 14

def name
  @name
end

#optionsHash<Symbol, Object> (readonly)

Returns The annotation’s options.

Returns:

  • (Hash<Symbol, Object>)

    The annotation’s options



18
19
20
# File 'lib/annotable/annotation.rb', line 18

def options
  @options
end

#paramsArray<Object> (readonly)

Returns The annotation’s params.

Returns:

  • (Array<Object>)

    The annotation’s params



16
17
18
# File 'lib/annotable/annotation.rb', line 16

def params
  @params
end