Class: Licensee::Rule
- Inherits:
-
Object
- Object
- Licensee::Rule
- Includes:
- HashHelper
- Defined in:
- lib/licensee/rule.rb
Constant Summary collapse
- HASH_METHODS =
%i[tag label description].freeze
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Class Method Summary collapse
- .all ⇒ Object
- .file_path ⇒ Object
- .find_by_tag_and_group(tag, group = nil) ⇒ Object (also: find_by_tag)
- .groups ⇒ Object
- .raw_rules ⇒ Object
Instance Method Summary collapse
-
#initialize(tag: nil, label: nil, description: nil, group: nil) ⇒ Rule
constructor
A new instance of Rule.
- #inspect ⇒ Object
Methods included from HashHelper
Constructor Details
#initialize(tag: nil, label: nil, description: nil, group: nil) ⇒ Rule
Returns a new instance of Rule.
10 11 12 13 14 15 |
# File 'lib/licensee/rule.rb', line 10 def initialize(tag: nil, label: nil, description: nil, group: nil) @tag = tag @label = label @description = description @group = group end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/licensee/rule.rb', line 5 def description @description end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
5 6 7 |
# File 'lib/licensee/rule.rb', line 5 def group @group end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
5 6 7 |
# File 'lib/licensee/rule.rb', line 5 def label @label end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
5 6 7 |
# File 'lib/licensee/rule.rb', line 5 def tag @tag end |
Class Method Details
.all ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/licensee/rule.rb', line 22 def all @all ||= raw_rules.map do |group, rules| rules.map do |rule| Rule.new( tag: rule['tag'], label: rule['label'], description: rule['description'], group: group ) end end.flatten end |
.file_path ⇒ Object
40 41 42 43 |
# File 'lib/licensee/rule.rb', line 40 def file_path dir = File.dirname(__FILE__) File. '../../vendor/choosealicense.com/_data/rules.yml', dir end |
Instance Method Details
#inspect ⇒ Object
17 18 19 |
# File 'lib/licensee/rule.rb', line 17 def inspect "#<Licensee::Rule @tag=\"#{tag}\">" end |