Class: Cog::DSL::FeatureDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/cog/dsl/feature_dsl.rb

Overview

DSL for defining cog features

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seed, name, opt = {}) ⇒ FeatureDSL

Returns a new instance of FeatureDSL.



12
13
14
# File 'lib/cog/dsl/feature_dsl.rb', line 12

def initialize(seed, name, opt={})
  @feature = Seed::Feature.new seed, name, opt
end

Instance Attribute Details

#featureCog::Seed (readonly)

Returns the seed which is defined by this DSL object.

Returns:

  • (Cog::Seed)

    the seed which is defined by this DSL object



9
10
11
# File 'lib/cog/dsl/feature_dsl.rb', line 9

def feature
  @feature
end

Instance Method Details

#abstractnil

Declare this method abstract

Returns:

  • (nil)


26
27
28
29
# File 'lib/cog/dsl/feature_dsl.rb', line 26

def abstract
  feature_eval { @abstract = true }
  nil
end

#desc(value) ⇒ nil

Describe what this method does in one line

Parameters:

  • value (String)

    a short description

Returns:

  • (nil)


19
20
21
22
# File 'lib/cog/dsl/feature_dsl.rb', line 19

def desc(value)
  feature_eval { @desc = value }
  nil
end

#param(type, name, opt = {}) ⇒ nil

Add a parameter to the feature

Parameters:

  • type (Symbol)

    the type of the parameter

  • name (String)

    name of the parameter

  • opt (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opt):

  • :desc (String) — default: nil

    optional description which will be used in documentation

  • :scope (Seed) — default: nil

    optional scope to use when rendering the variable in a qualified way

Returns:

  • (nil)


37
38
39
40
41
# File 'lib/cog/dsl/feature_dsl.rb', line 37

def param(type, name, opt={})
  v = Seed::Var.new type, name, opt
  feature_eval { @params << v }
  nil
end

#return(type) ⇒ nil

Define the return type for the method. Will be ‘:void` if this method is never called.

Parameters:

Returns:

  • (nil)


47
48
49
50
# File 'lib/cog/dsl/feature_dsl.rb', line 47

def return(type)
  feature_eval { @return_type = type }
  nil
end