Class: CKick::CompilerFlag

Inherits:
Object
  • Object
show all
Defined in:
lib/ckick/compiler_flag.rb

Overview

represents a compiler flag to pass to the compiler

Direct Known Subclasses

CFlag, CXXFlag

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ CompilerFlag

  • args - Hash containing flag data as String

Input hash keys

  • :flag - raw flag content, must be String



16
17
18
19
20
21
22
# File 'lib/ckick/compiler_flag.rb', line 16

def initialize args={}
  raise IllegalInitializationError, "No flag provided to compiler flag" unless args.is_a?(Hash) && !args.empty?
  flag = args[:flag] || nil
  raise BadFlagError, "Bad flag content provided to compiler flag" unless flag.is_a?(String) && !flag.empty?

  @content = args[:flag]
end

Instance Attribute Details

#contentObject (readonly)

raw flag



11
12
13
# File 'lib/ckick/compiler_flag.rb', line 11

def content
  @content
end

Instance Method Details

#eql?(other) ⇒ Boolean

overrides Object#eql? for uniqueness

Returns:

  • (Boolean)


40
41
42
# File 'lib/ckick/compiler_flag.rb', line 40

def eql? other
  @content.eql? other.content
end

#hashObject

overrides Object#hash for uniqueness



45
46
47
# File 'lib/ckick/compiler_flag.rb', line 45

def hash
  @content.hash
end

#raw_flagObject

raw flag



35
36
37
# File 'lib/ckick/compiler_flag.rb', line 35

def raw_flag
  @content
end

#to_hash_elementObject

converts to hash element: String



30
31
32
# File 'lib/ckick/compiler_flag.rb', line 30

def to_hash_element
  @content
end

#to_sObject

converts to String, flag as is



25
26
27
# File 'lib/ckick/compiler_flag.rb', line 25

def to_s
  @content
end