Class: Tableficate::Filter::Choice

Inherits:
Object
  • Object
show all
Defined in:
lib/tableficate/filters/choice.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value, options = {}) ⇒ Choice

Returns a new instance of Choice.



6
7
8
9
10
11
12
13
14
15
# File 'lib/tableficate/filters/choice.rb', line 6

def initialize(name, value, options = {})
  @name  = name
  @value = value

  @selected = !!(options.has_key?(:selected) || options.has_key?(:checked))
  options.delete(:selected)
  options.delete(:checked)

  @attrs = options
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



4
5
6
# File 'lib/tableficate/filters/choice.rb', line 4

def attrs
  @attrs
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/tableficate/filters/choice.rb', line 4

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/tableficate/filters/choice.rb', line 4

def value
  @value
end

Instance Method Details

#selected?Boolean Also known as: checked?

Returns:

  • (Boolean)


17
18
19
# File 'lib/tableficate/filters/choice.rb', line 17

def selected?
  @selected
end