Class: Lazylead::Opts
- Inherits:
-
Object
- Object
- Lazylead::Opts
- Extended by:
- Forwardable
- Defined in:
- lib/lazylead/opts.rb
Overview
Default options for all lazylead tasks.
- Author
-
Yurii Dubinka ([email protected])
- Copyright
-
Copyright © 2019-2020 Yurii Dubinka
- License
-
MIT
Instance Method Summary collapse
- #blank?(key) ⇒ Boolean
-
#initialize(origin = {}) ⇒ Opts
constructor
A new instance of Opts.
-
#jira_defaults ⇒ Object
Default Jira options to use during search for all Jira-based tasks.
-
#jira_fields ⇒ Object
Default fields which to fetch within the Jira issue.
-
#slice(key, delim) ⇒ Object
Split text value by delimiter, trim all spaces and reject blank items.
- #to_h ⇒ Object
Constructor Details
#initialize(origin = {}) ⇒ Opts
Returns a new instance of Opts.
38 39 40 |
# File 'lib/lazylead/opts.rb', line 38 def initialize(origin = {}) @origin = origin end |
Instance Method Details
#blank?(key) ⇒ Boolean
47 48 49 |
# File 'lib/lazylead/opts.rb', line 47 def blank?(key) to_h[key].nil? || @origin[key].blank? end |
#jira_defaults ⇒ Object
Default Jira options to use during search for all Jira-based tasks.
56 57 58 59 60 61 |
# File 'lib/lazylead/opts.rb', line 56 def jira_defaults { max_results: fetch("max_results", 50), fields: jira_fields } end |
#jira_fields ⇒ Object
Default fields which to fetch within the Jira issue
64 65 66 |
# File 'lib/lazylead/opts.rb', line 64 def jira_fields to_h.fetch("fields", "").split(",").map(&:to_sym) end |
#slice(key, delim) ⇒ Object
Split text value by delimiter, trim all spaces and reject blank items
43 44 45 |
# File 'lib/lazylead/opts.rb', line 43 def slice(key, delim) to_h[key].split(delim).map(&:chomp).map(&:strip).reject(&:blank?) end |
#to_h ⇒ Object
51 52 53 |
# File 'lib/lazylead/opts.rb', line 51 def to_h @origin end |