Class: Swagger::Data::License

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-swagger/data/license.rb

Overview

Constant Summary collapse

DEFAULT_NAME =
'Apache 2.0'
DEFAULT_URL =
'http://www.apache.org/licenses/LICENSE-2.0.html'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

attr_swagger, #bulk_set, #swagger_attributes, #to_json, #to_swagger, #to_yaml

Constructor Details

#initializeLicense

Returns a new instance of License.



11
12
13
14
# File 'lib/ruby-swagger/data/license.rb', line 11

def initialize
  @name = DEFAULT_NAME
  @url = Swagger::Data::Url.new(DEFAULT_URL)
end

Class Method Details

.parse(license) ⇒ Object



16
17
18
19
20
# File 'lib/ruby-swagger/data/license.rb', line 16

def self.parse(license)
  return nil unless license

  Swagger::Data::License.new.bulk_set(license)
end

Instance Method Details

#name=(new_name) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
# File 'lib/ruby-swagger/data/license.rb', line 22

def name=(new_name)
  raise ArgumentError.new('Swagger::Data::License - license name is invalid ') if new_name.nil? || new_name.empty?
  @name = new_name
end

#urlObject



35
36
37
# File 'lib/ruby-swagger/data/license.rb', line 35

def url
  @url.url
end

#url=(url) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/ruby-swagger/data/license.rb', line 27

def url=(url)
  return nil unless url

  @url = Swagger::Data::Url.new(url)
  validate_url!
  @url
end

#valid?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ruby-swagger/data/license.rb', line 39

def valid?
  @url.valid?
end