Class: EnumeratedAttribute::MethodDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/enumerated_attribute/method_definition_dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, arg, negated = false) ⇒ MethodDefinition

Returns a new instance of MethodDefinition.



6
7
8
# File 'lib/enumerated_attribute/method_definition_dsl.rb', line 6

def initialize(name, arg, negated=false)
  @method_name, @negated, @argument = name, negated, arg
end

Instance Attribute Details

#argumentObject

Returns the value of attribute argument.



4
5
6
# File 'lib/enumerated_attribute/method_definition_dsl.rb', line 4

def argument
  @argument
end

#method_nameObject

Returns the value of attribute method_name.



4
5
6
# File 'lib/enumerated_attribute/method_definition_dsl.rb', line 4

def method_name
  @method_name
end

#negatedObject

Returns the value of attribute negated.



4
5
6
# File 'lib/enumerated_attribute/method_definition_dsl.rb', line 4

def negated
  @negated
end

Instance Method Details

#has_argument?Boolean

Returns:

  • (Boolean)


12
# File 'lib/enumerated_attribute/method_definition_dsl.rb', line 12

def has_argument?; !!@argument; end

#has_method_name?Boolean

Returns:

  • (Boolean)


11
# File 'lib/enumerated_attribute/method_definition_dsl.rb', line 11

def has_method_name?; !!@method_name; end

#is_predicate_method?Boolean

Returns:

  • (Boolean)


10
# File 'lib/enumerated_attribute/method_definition_dsl.rb', line 10

def is_predicate_method?; @method_name[-1, 1] == '?'; end