Class: Eco::API::UseCases::GraphQL::Helpers::Location::TagsRemap::TagsSet
- Defined in:
- lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb
Constant Summary collapse
- COMPARE_METHODS =
%i[< <= == > >=].freeze
- OPERATE_METHODS =
%i[& + - ^].freeze
Instance Attribute Summary collapse
-
#set ⇒ Object
readonly
Returns the value of attribute set.
Class Method Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #include?(value) ⇒ Boolean
- #include_any?(value) ⇒ Boolean
-
#initialize(tags) ⇒ TagsSet
constructor
A new instance of TagsSet.
- #length ⇒ Object
- #subset_of?(value) ⇒ Boolean
- #superset_of?(value) ⇒ Boolean
- #tags ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(tags) ⇒ TagsSet
Returns a new instance of TagsSet.
32 33 34 35 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 32 def initialize() @ini_tags = value_to_a() @set = to_set() end |
Instance Attribute Details
#set ⇒ Object (readonly)
Returns the value of attribute set.
30 31 32 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 30 def set @set end |
Class Method Details
.attr_compare(*attrs) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 5 def attr_compare(*attrs) attrs.each do |attr| meth = "#{attr}".to_sym # rubocop:disable Style/RedundantInterpolation define_method meth do |value| set.send(meth, to_set(value)) end end end |
.attr_operate(*attrs) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 14 def attr_operate(*attrs) attrs.each do |attr| meth = "#{attr}".to_sym # rubocop:disable Style/RedundantInterpolation define_method meth do |value| self.class.new(set.send(meth, to_set(value))) end end end |
Instance Method Details
#empty? ⇒ Boolean
53 54 55 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 53 def empty? set.empty? end |
#include?(value) ⇒ Boolean
57 58 59 60 61 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 57 def include?(value) value = value.to_s.strip return false if value.empty? set.include?(value) end |
#include_any?(value) ⇒ Boolean
63 64 65 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 63 def include_any?(value) value.to_a.any? {|tag| include?(tag)} end |
#length ⇒ Object
37 38 39 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 37 def length set.length end |
#subset_of?(value) ⇒ Boolean
67 68 69 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 67 def subset_of?(value) set.subset?(to_set(value)) end |
#superset_of?(value) ⇒ Boolean
71 72 73 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 71 def superset_of?(value) set.superset?(to_set(value)) end |
#tags ⇒ Object
41 42 43 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 41 def .compact.map(&:upcase) end |
#to_a ⇒ Object
45 46 47 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 45 def to_a end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/eco/api/usecases/graphql/helpers/location/tags_remap/tags_set.rb', line 49 def to_s .join('|') end |