Class: Options::PartialOptions
- Inherits:
-
Object
- Object
- 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
Constructor Details
#initialize(options) ⇒ PartialOptions
Returns a new instance of PartialOptions.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/filterameter/options/partial_options.rb', line 21 def initialize() @match = 'anywhere' @case_sensitive = false if .is_a?(TrueClass) nil elsif .is_a? Hash evaluate_hash() elsif .is_a?(String) || .is_a?(Symbol) assign_match() end end |
Instance Method Details
#case_sensitive? ⇒ Boolean
34 35 36 |
# File 'lib/filterameter/options/partial_options.rb', line 34 def case_sensitive? @case_sensitive end |
#match_anywhere? ⇒ Boolean
38 39 40 |
# File 'lib/filterameter/options/partial_options.rb', line 38 def match_anywhere? @match == 'anywhere' end |
#match_dynamically? ⇒ Boolean
46 47 48 |
# File 'lib/filterameter/options/partial_options.rb', line 46 def match_dynamically? @match == 'dynamic' end |
#match_from_start? ⇒ Boolean
42 43 44 |
# File 'lib/filterameter/options/partial_options.rb', line 42 def match_from_start? @match == 'from_start' end |