Class: Filterameter::Options::PartialOptions
- Inherits:
-
Object
- Object
- Filterameter::Options::PartialOptions
- Defined in:
- lib/filterameter/options/partial_options.rb
Overview
Partial Options
Class PartialOptions parses the options passed in as partial, then exposes those. Here are the options along with their valid values:
-
match: anywhere (default), from_start, dynamic
-
case_sensitive: true, false (default)
Options may be specified by passing a hash with the option keys:
partial: { match: :from_start, case_sensitive: true }
There are two shortcuts: the partial option can be declared with true, which just uses the defaults; or the partial option can be declared with the match option directly, such as partial: :from_start.
Constant Summary collapse
- VALID_OPTIONS =
i[match case_sensitive].freeze
- VALID_MATCH_OPTIONS =
%w[anywhere from_start dynamic].freeze
Instance Method Summary collapse
- #case_sensitive? ⇒ Boolean
-
#initialize(options) ⇒ PartialOptions
constructor
A new instance of PartialOptions.
- #match_anywhere? ⇒ Boolean
- #match_dynamically? ⇒ Boolean
- #match_from_start? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(options) ⇒ PartialOptions
Returns a new instance of PartialOptions.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/filterameter/options/partial_options.rb', line 22 def initialize() @match = 'anywhere' @case_sensitive = false case when TrueClass nil when Hash evaluate_hash() when String, Symbol assign_match() end end |
Instance Method Details
#case_sensitive? ⇒ Boolean
36 37 38 |
# File 'lib/filterameter/options/partial_options.rb', line 36 def case_sensitive? @case_sensitive end |
#match_anywhere? ⇒ Boolean
40 41 42 |
# File 'lib/filterameter/options/partial_options.rb', line 40 def match_anywhere? @match == 'anywhere' end |
#match_dynamically? ⇒ Boolean
48 49 50 |
# File 'lib/filterameter/options/partial_options.rb', line 48 def match_dynamically? @match == 'dynamic' end |
#match_from_start? ⇒ Boolean
44 45 46 |
# File 'lib/filterameter/options/partial_options.rb', line 44 def match_from_start? @match == 'from_start' end |
#to_s ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/filterameter/options/partial_options.rb', line 52 def to_s if case_sensitive? case_sensitive_to_s elsif match_anywhere? 'true' else ":#{@match}" end end |