Class: Travis::Encrypt::Encryptor

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/travis/encrypt/encryptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#add_iv, #create_aes, #create_iv, #decode, #encode, #extract_iv

Constructor Details

#initialize(string, options) ⇒ Encryptor

Returns a new instance of Encryptor.



10
11
12
13
14
# File 'lib/travis/encrypt/encryptor.rb', line 10

def initialize(string, options)
  @string  = string
  @key     = options[:key] || fail("Need to pass a key")
  @options = options || {}
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/travis/encrypt/encryptor.rb', line 8

def key
  @key
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/travis/encrypt/encryptor.rb', line 8

def options
  @options
end

#stringObject (readonly)

Returns the value of attribute string.



8
9
10
# File 'lib/travis/encrypt/encryptor.rb', line 8

def string
  @string
end

Instance Method Details

#applyObject



20
21
22
# File 'lib/travis/encrypt/encryptor.rb', line 20

def apply
  apply? ? encrypt : string
end

#apply?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/travis/encrypt/encryptor.rb', line 16

def apply?
  !!string && !string.empty? && !options[:disable] # TODO ask piotr
end