Class: Spec

Inherits:
Object
  • Object
show all
Defined in:
lib/juxtapose/application/lib/spec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(basedir, path) ⇒ Spec

Returns a new instance of Spec.



4
5
6
7
# File 'lib/juxtapose/application/lib/spec.rb', line 4

def initialize(basedir, path)
  self.basedir = basedir
  self.path = path
end

Instance Attribute Details

#basedirObject

Returns the value of attribute basedir.



2
3
4
# File 'lib/juxtapose/application/lib/spec.rb', line 2

def basedir
  @basedir
end

#pathObject

Returns the value of attribute path.



2
3
4
# File 'lib/juxtapose/application/lib/spec.rb', line 2

def path
  @path
end

Instance Method Details

#acceptedObject



23
24
25
# File 'lib/juxtapose/application/lib/spec.rb', line 23

def accepted
  images.select(&:accepted?).first
end

#as_jsonObject



35
36
37
38
39
40
41
42
# File 'lib/juxtapose/application/lib/spec.rb', line 35

def as_json
  {
    directory: path,
    accepted: accepted,
    current: current,
    diff: diff
  }
end

#currentObject



27
28
29
# File 'lib/juxtapose/application/lib/spec.rb', line 27

def current
  images.select(&:current?).first
end

#diffObject



31
32
33
# File 'lib/juxtapose/application/lib/spec.rb', line 31

def diff
  images.select(&:diff?).first
end

#imagesObject



9
10
11
12
13
# File 'lib/juxtapose/application/lib/spec.rb', line 9

def images
  Dir.glob(File.join(path, '*.png')).map do |img|
    Image.new(basedir, img)
  end
end

#nameObject



15
16
17
# File 'lib/juxtapose/application/lib/spec.rb', line 15

def name
  path.gsub(basedir, '')
end

#to_jsonObject



19
20
21
# File 'lib/juxtapose/application/lib/spec.rb', line 19

def to_json
  as_json.to_json
end