Class: Cuker::AbstractModel
- Inherits:
-
Object
- Object
- Cuker::AbstractModel
- Includes:
- IModel, LoggerSetup
- Defined in:
- lib/cuker/helpers/formatters/abstract_model.rb
Direct Known Subclasses
Constant Summary collapse
- FEATURE =
'Feature'
- BACKGROUND =
'Background'
- SCENARIO =
'Scenario'
- SCENARIO_OUTLINE =
'Scenario Outline'
- EXAMPLES =
'Examples'
- GIVEN =
'Given'
- WHEN =
'When'
- THEN =
'Then'
- AND =
'And'
- BUT =
'But'
Instance Attribute Summary collapse
-
#data ⇒ Array
Writable array of rows of data Defaults to [].
-
#title ⇒ Array
Writable rows of title Defaults to [].
Attributes included from LoggerSetup
Instance Method Summary collapse
- #get_keys_ary(ary_of_hshs) ⇒ Object
-
#get_tags(hsh) ⇒ Object
def padded_surround item, sep, pad “#sep#pad#item#pad#sep” end.
- #get_values_ary(ary_of_hshs) ⇒ Object
-
#initialize(_model_input = []) ⇒ AbstractModel
constructor
A new instance of AbstractModel.
-
#name_merge(hsh) ⇒ Object
utility methods used by any model.
- #simple_surround(item, sep, r_sep = nil) ⇒ Object
-
#surround(ary, sep) ⇒ String
With an array surrounded by the sep.
- #union(feat_tags, tags) ⇒ Object
Methods included from Interface
Methods included from LoggerSetup
#init_logger, reset_appender_log_levels
Constructor Details
#initialize(_model_input = []) ⇒ AbstractModel
Returns a new instance of AbstractModel.
39 40 41 42 43 |
# File 'lib/cuker/helpers/formatters/abstract_model.rb', line 39 def initialize _model_input = [] init_logger @title = [] @data = [] end |
Instance Attribute Details
#data ⇒ Array
Returns writable array of rows of data Defaults to [].
23 24 25 |
# File 'lib/cuker/helpers/formatters/abstract_model.rb', line 23 def data @data end |
#title ⇒ Array
Returns writable rows of title Defaults to [].
19 20 21 |
# File 'lib/cuker/helpers/formatters/abstract_model.rb', line 19 def title @title end |
Instance Method Details
#get_keys_ary(ary_of_hshs) ⇒ Object
49 50 51 |
# File 'lib/cuker/helpers/formatters/abstract_model.rb', line 49 def get_keys_ary ary_of_hshs get_item_ary ary_of_hshs, :keys end |
#get_tags(hsh) ⇒ Object
def padded_surround item, sep, pad
"#{sep}#{pad}#{item}#{pad}#{sep}"
end
84 85 86 87 88 89 90 91 |
# File 'lib/cuker/helpers/formatters/abstract_model.rb', line 84 def (hsh) if hsh[:tags] and hsh[:tags].any? hsh[:tags].map {|tag| tag[:name]} else @log.debug "No Tags found in #{hsh[:keyword]} @ #{@file_path}" [] end end |
#get_values_ary(ary_of_hshs) ⇒ Object
45 46 47 |
# File 'lib/cuker/helpers/formatters/abstract_model.rb', line 45 def get_values_ary ary_of_hshs get_item_ary ary_of_hshs, :values end |
#name_merge(hsh) ⇒ Object
utility methods used by any model
56 57 58 59 60 61 62 |
# File 'lib/cuker/helpers/formatters/abstract_model.rb', line 56 def name_merge hsh str = "" @log.debug "name merge for #{hsh}" str += hsh[:name].strip.force_encoding("UTF-8") if hsh[:name] str += "\n#{hsh[:description].strip.force_encoding("UTF-8")}" if hsh[:description] str end |
#simple_surround(item, sep, r_sep = nil) ⇒ Object
76 77 78 |
# File 'lib/cuker/helpers/formatters/abstract_model.rb', line 76 def simple_surround item, sep, r_sep = nil "#{sep}#{item}#{r_sep || sep}" end |
#surround(ary, sep) ⇒ String
Returns with an array surrounded by the sep.
70 71 72 73 74 |
# File 'lib/cuker/helpers/formatters/abstract_model.rb', line 70 def surround ary, sep # "#{sep}#{ary.is_a?(Array)? ary.join(sep) : ary}#{sep}" # "#{sep}#{ary.join(sep)}#{sep}" simple_surround ary.join(sep), sep end |
#union(feat_tags, tags) ⇒ Object
64 65 66 |
# File 'lib/cuker/helpers/formatters/abstract_model.rb', line 64 def union , (.to_set | .to_set).to_a # union end |