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.
8 9 10 11 12 13 |
# File 'lib/licensee/rule.rb', line 8 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.
3 4 5 |
# File 'lib/licensee/rule.rb', line 3 def description @description end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
3 4 5 |
# File 'lib/licensee/rule.rb', line 3 def group @group end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
3 4 5 |
# File 'lib/licensee/rule.rb', line 3 def label @label end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
3 4 5 |
# File 'lib/licensee/rule.rb', line 3 def tag @tag end |
Class Method Details
.all ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/licensee/rule.rb', line 20 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
38 39 40 41 |
# File 'lib/licensee/rule.rb', line 38 def file_path dir = File.dirname(__FILE__) File. '../../vendor/choosealicense.com/_data/rules.yml', dir end |
Instance Method Details
#inspect ⇒ Object
15 16 17 |
# File 'lib/licensee/rule.rb', line 15 def inspect "#<Licensee::Rule @tag=\"#{tag}\">" end |