Class: Elm::Files

Inherits:
Object
  • Object
show all
Includes:
Contracts::Builtin, Contracts::Core
Defined in:
lib/elm/files.rb

Overview

Elm files to be compiled

Instance Method Summary collapse

Constructor Details

#initialize(make, files, options) ⇒ Files

Returns a new instance of Files.



43
44
45
46
47
48
49
# File 'lib/elm/files.rb', line 43

def initialize(make, files, options)
  @make = make
  @files = files
  @options = options.with_yes

  self
end

Instance Method Details

#to_fileObject



63
64
65
66
# File 'lib/elm/files.rb', line 63

def to_file
  run_status = compile
  CompileOutput.new @options.output, run_status
end

#to_sObject



52
53
54
55
56
57
58
59
60
# File 'lib/elm/files.rb', line 52

def to_s
  content = ''
  run_status = nil
  Tempfile.open(['elm', '.js']) do |tempfile|
    run_status = compile @options.with_output(tempfile.path)
    content = File.read tempfile
  end
  CompileOutput.new content, run_status
end