Class: Licensee::License
- Inherits:
-
Object
- Object
- Licensee::License
- Defined in:
- lib/licensee/license.rb
Instance Attribute Summary collapse
-
#match ⇒ Object
Returns the value of attribute match.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #body ⇒ Object (also: #to_s)
- #content ⇒ Object
-
#initialize(name) ⇒ License
constructor
A new instance of License.
- #inspect ⇒ Object
- #length ⇒ Object
- #meta ⇒ Object
- #parts ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(name) ⇒ License
Returns a new instance of License.
7 8 9 |
# File 'lib/licensee/license.rb', line 7 def initialize(name) @name=name end |
Instance Attribute Details
#match ⇒ Object
Returns the value of attribute match.
5 6 7 |
# File 'lib/licensee/license.rb', line 5 def match @match end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/licensee/license.rb', line 4 def name @name end |
Instance Method Details
#body ⇒ Object Also known as: to_s
33 34 35 |
# File 'lib/licensee/license.rb', line 33 def body @body ||= parts[2] end |
#content ⇒ Object
15 16 17 |
# File 'lib/licensee/license.rb', line 15 def content @content ||= File.open(path).read end |
#inspect ⇒ Object
38 39 40 41 42 43 |
# File 'lib/licensee/license.rb', line 38 def inspect s = "#<Licensee::License name=\"#{name}\"" s += " match=#{match}" if match s += ">" s end |
#length ⇒ Object
29 30 31 |
# File 'lib/licensee/license.rb', line 29 def length @length ||= body.length end |
#meta ⇒ Object
23 24 25 26 27 |
# File 'lib/licensee/license.rb', line 23 def @meta ||= front_matter = YAML.load(parts[1]) if parts[1] rescue nil end |
#parts ⇒ Object
19 20 21 |
# File 'lib/licensee/license.rb', line 19 def parts @parts ||= content.match /^(---\n.*\n---)?(.*)/m end |