Class: Extracter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/extracter/base/base.rb

Overview

Extracter::Base

Direct Known Subclasses

ExtractIt, Extracter

Instance Method Summary collapse

Instance Method Details

#change_directory(i) ⇒ Object Also known as: cd

#

change_directory

#


163
164
165
# File 'lib/extracter/base/base.rb', line 163

def change_directory(i)
  Dir.chdir(i)
end

#check_whether_the_colours_gem_is_availableObject

#

check_whether_the_colours_gem_is_available

#


41
42
43
44
45
46
47
48
49
50
# File 'lib/extracter/base/base.rb', line 41

def check_whether_the_colours_gem_is_available
  if Object.const_defined?(:Colours) and
     Colours.respond_to?(:simp) and
     Colours.respond_to?(:sfancy) and
     Colours.respond_to?(:sdir) and
     Colours.respond_to?(:simp)
  else
    @internal_hash[:use_colours] = false
  end
end

#cpr(a, b) ⇒ Object

#

cpr

#


138
139
140
141
# File 'lib/extracter/base/base.rb', line 138

def cpr(a, b)
  require 'fileutils' unless Object.const_defined?(:FileUtils)
  FileUtils.cp_r(a, b)
end

#cyan?Boolean

#

cyan

#

Returns:

  • (Boolean)


55
56
57
58
# File 'lib/extracter/base/base.rb', line 55

def cyan?
  return Colours::CYAN if Object.const_defined?(:Colours) and use_colours?
  return ''
end

#e(i = '') ⇒ Object

#

e (e tag)

#


131
132
133
# File 'lib/extracter/base/base.rb', line 131

def e(i = '')
  puts i
end

#ewarn(i = '') ⇒ Object

#

ewarn

#


87
88
89
90
91
92
93
# File 'lib/extracter/base/base.rb', line 87

def ewarn(i = '')
  if use_colours? and Object.const_defined?(:Colours)
    e Colours.swarn(i)
  else
    e i
  end
end

#move(a, b) ⇒ Object Also known as: mv

#

move

#


146
147
148
149
# File 'lib/extracter/base/base.rb', line 146

def move(a, b)
  require 'fileutils' unless Object.const_defined?(:FileUtils)
  FileUtils.mv(a, b)
end

#remove_this_directory(i) ⇒ Object

#

remove_this_directory

#


154
155
156
157
158
# File 'lib/extracter/base/base.rb', line 154

def remove_this_directory(i)
  if File.directory? i
    FileUtils.rm_r(i) unless i == '/'
  end
end

#resetObject

#

reset

#


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/extracter/base/base.rb', line 25

def reset
  # ======================================================================= #
  # === @internal_hash
  # ======================================================================= #
  @internal_hash = {}
  # ======================================================================= #
  # === :use_colours
  # ======================================================================= #
  @internal_hash[:use_colours] = true
  # Next check whether the Colours gem is available.
  check_whether_the_colours_gem_is_available
end

#revObject

#

rev

#


170
171
172
# File 'lib/extracter/base/base.rb', line 170

def rev
  ::Colours.rev
end

#sdir(i = '') ⇒ Object

#

sdir

#


114
115
116
117
# File 'lib/extracter/base/base.rb', line 114

def sdir(i = '')
  return Colours.sdir(i) if use_colours?
  return i
end

#sfancy(i = '') ⇒ Object

#

sfancy

#


106
107
108
109
# File 'lib/extracter/base/base.rb', line 106

def sfancy(i = '')
  return Colours.sfancy(i) if use_colours?
  return i
end

#sfile(i = '') ⇒ Object

#

sfile

#


98
99
100
101
# File 'lib/extracter/base/base.rb', line 98

def sfile(i = '')
  return Colours.sfancy(i) if use_colours?
  return i
end

#simp(i = '') ⇒ Object

#

simp

#


71
72
73
74
# File 'lib/extracter/base/base.rb', line 71

def simp(i = '')
  return Colours.simp(i) if use_colours?
  return i
end

#steelblue(i = '') ⇒ Object

#

steelblue

#


79
80
81
82
# File 'lib/extracter/base/base.rb', line 79

def steelblue(i = '')
  return ::Colours.steelblue(i) if use_colours? and ::Colours.respond_to?(:steelblue)
  return i
end

#tomato(i = '', use_colours = use_colours?) ) ⇒ Object

#

tomato

#


63
64
65
66
# File 'lib/extracter/base/base.rb', line 63

def tomato(i = '', use_colours = use_colours?)
  return Colours.tomato(i) if use_colours
  return i
end

#use_colours?Boolean Also known as: colours?

#

use_colours?

Determine whether we will use colours in class Extracter.

#

Returns:

  • (Boolean)


124
125
126
# File 'lib/extracter/base/base.rb', line 124

def use_colours?
  @internal_hash[:use_colours]
end