Class: Narabikae::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/narabikae/option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field:, key_max_size:, scope: [], default_position: :last) ⇒ Option

Initializes a new instance of the Option class.

Parameters:

  • field (Symbol)
  • key_max_size (Integer)

    The maximum size of the key.

  • scope (Symbol, Array<Symbol>) (defaults to: [])

    The scope of the option.

  • default_position (Symbol) (defaults to: :last)

    The default position when creating or auto setting.



11
12
13
14
15
16
17
18
19
20
# File 'lib/narabikae/option.rb', line 11

def initialize(field:, key_max_size:, scope: [], default_position: :last)
  @field = field.to_sym
  @key_max_size = key_max_size.to_i
  @scope = Array.wrap(scope).map(&:to_sym)
  @default_position = (default_position || :last).to_sym

  unless i[first last].include?(@default_position)
    raise ArgumentError, "default_position must be :first or :last"
  end
end

Instance Attribute Details

#default_positionObject (readonly)

Returns the value of attribute default_position.



3
4
5
# File 'lib/narabikae/option.rb', line 3

def default_position
  @default_position
end

#fieldObject (readonly)

Returns the value of attribute field.



3
4
5
# File 'lib/narabikae/option.rb', line 3

def field
  @field
end

#key_max_sizeObject (readonly)

Returns the value of attribute key_max_size.



3
4
5
# File 'lib/narabikae/option.rb', line 3

def key_max_size
  @key_max_size
end

#scopeObject (readonly)

Returns the value of attribute scope.



3
4
5
# File 'lib/narabikae/option.rb', line 3

def scope
  @scope
end