Class: Bootinq::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/bootinq/component.rb

Direct Known Subclasses

Mountable

Instance Attribute Summary collapse

Coercing methods collapse

Comparation methods collapse

Symbol-delegated methods collapse

String-delegated methods collapse

Symbol-delegated mutation methods collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(intern) ⇒ self

Parameters:

  • intern (String, Symbol)


34
35
36
37
38
# File 'lib/bootinq/component.rb', line 34

def initialize(intern)
  @intern = intern.to_sym
  @id2name = intern.to_s.freeze
  @group = :"#{@id2name}_boot"
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



18
19
20
# File 'lib/bootinq/component.rb', line 18

def group
  @group
end

#id2nameObject (readonly) Also known as: to_s, gem_name, name

Returns the value of attribute id2name.



13
14
15
# File 'lib/bootinq/component.rb', line 13

def id2name
  @id2name
end

#internObject (readonly) Also known as: to_sym

Returns the value of attribute intern.



8
9
10
# File 'lib/bootinq/component.rb', line 8

def intern
  @intern
end

Class Method Details

.new(intern) ⇒ Bootinq::Component

Returns frozen.

Parameters:

  • intern (String, Symbol)

Returns:

See Also:



28
29
30
# File 'lib/bootinq/component.rb', line 28

def self.new(intern)
  super.freeze
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Any)

Returns:

  • (Boolean)


108
109
110
111
# File 'lib/bootinq/component.rb', line 108

def ==(other)
  other = coerce(other)
  other == coerce_to(other)
end

#===(other) ⇒ Boolean

Parameters:

  • other (Any)

Returns:

  • (Boolean)


115
116
117
118
# File 'lib/bootinq/component.rb', line 115

def ===(other)
  other = coerce(other)
  other === coerce_to(other)
end

#=~(pattern) ⇒ Integer? #=~(arg) ⇒ Object

Overloads:

  • #=~(pattern) ⇒ Integer?

    Parameters:

    • pattern (Regexp)

    Returns:

    • (Integer)

      if matched, the position the match starts

    • (nil)

      if there is no match

  • #=~(arg) ⇒ Object

    Parameters:

    • arg (Object)

    See Also:

    • Object#=~


205
206
207
# File 'lib/bootinq/component.rb', line 205

def =~(arg)
  @id2name =~ arg
end

#__id__Integer

Returns identifier for #intern.

Returns:

  • (Integer)

    identifier for #intern



151
152
153
# File 'lib/bootinq/component.rb', line 151

def __id__
  @intern.__id__
end

#capitalizeBootinq::Component

Returns new instance with capitalized #intern.

Returns:

See Also:

  • Symbol#capitalize


237
238
239
# File 'lib/bootinq/component.rb', line 237

def capitalize
  self.class.new(@intern.capitalize)
end

#casecmp(other) ⇒ Boolean

Parameters:

  • other (Any)

Returns:

  • (Boolean)


122
123
124
125
# File 'lib/bootinq/component.rb', line 122

def casecmp(other)
  other = coerce(other)
  coerce_to(other).casecmp(other)
end

#casecmp?(other) ⇒ Boolean

Parameters:

  • other (Any)

Returns:

  • (Boolean)


129
130
131
132
# File 'lib/bootinq/component.rb', line 129

def casecmp?(other)
  other = coerce(other)
  coerce_to(other).casecmp?(other)
end

#coerce(symbol) ⇒ Symbol #coerce(other) ⇒ String

Coerces other value

Overloads:

  • #coerce(symbol) ⇒ Symbol

    Returns symbol.

    Parameters:

    • symbol (Symbol)

    Returns:

    • (Symbol)

      symbol

  • #coerce(other) ⇒ String

    Returns other.

    Parameters:

    • other (String, Any)

    Returns:

    • (String)

      other



93
94
95
96
97
98
# File 'lib/bootinq/component.rb', line 93

def coerce(other)
  case other
  when String, Symbol; other
  else other.to_s
  end
end

#coerce_to(string) ⇒ String #coerce_to(symbol) ⇒ Symbol #coerce_to(other) ⇒ self

Coerces self to other value klass.

Overloads:

  • #coerce_to(string) ⇒ String

    Returns #id2name.

    Parameters:

    • string (String)

    Returns:

  • #coerce_to(symbol) ⇒ Symbol

    Returns #intern.

    Parameters:

    • symbol (Symbol)

    Returns:

  • #coerce_to(other) ⇒ self

    Parameters:

    • other (Any)

    Returns:

    • (self)


78
79
80
81
82
83
84
# File 'lib/bootinq/component.rb', line 78

def coerce_to(other)
  case other
  when String; @id2name
  when Symbol; @intern
  else self
  end
end

#downcaseBootinq::Component

Returns new instance with downcased #intern.

Returns:

See Also:

  • Symbol#downcase


231
232
233
# File 'lib/bootinq/component.rb', line 231

def downcase
  self.class.new(@intern.downcase)
end

#empty?Boolean

Returns:

  • (Boolean)


172
173
174
# File 'lib/bootinq/component.rb', line 172

def empty?
  @id2name.empty?
end

#encodingEncoding

Returns of #id2name.

Returns:



167
168
169
# File 'lib/bootinq/component.rb', line 167

def encoding
  @id2name.encoding
end

#engine

This method returns an undefined value.



56
57
# File 'lib/bootinq/component.rb', line 56

def engine
end

#hashInteger

Returns #intern's hash.

Returns:



156
157
158
# File 'lib/bootinq/component.rb', line 156

def hash
  @intern.hash
end

#inspectString

Returns representation of #intern as a symbol literal.

Returns:

  • (String)

    representation of #intern as a symbol literal.



141
142
143
# File 'lib/bootinq/component.rb', line 141

def inspect
  @intern.inspect
end

#kind_of?(klass) ⇒ Boolean

Parameters:

  • klass (Class)

Returns:

  • (Boolean)


61
62
63
# File 'lib/bootinq/component.rb', line 61

def kind_of?(klass)
  super || @intern.kind_of?(klass)
end

#lengthInteger

Returns length of #id2name.

Returns:



177
178
179
# File 'lib/bootinq/component.rb', line 177

def length
  @id2name.length
end

#match(*args) {|MatchData| ... } ⇒ MatchData, Any

Parameters:

  • pattern (Regexp, String)
  • start_from (Integer)

    position in #id2name to begin the search

Yields:

  • (MatchData)

    if match succeed

Yield Returns:

  • (Any)

Returns:

  • (MatchData)

    unless block given

  • (Any)

    returned by the given block



187
188
189
# File 'lib/bootinq/component.rb', line 187

def match(*args, &block)
  @id2name.match(*args, &block)
end

#match?(*args) ⇒ Boolean

Returns indicates whether the regexp is matched or not.

Parameters:

  • pattern (Regexp, String)
  • start_from (Integer)

    position in #id2name to begin the search

Returns:

  • (Boolean)

    indicates whether the regexp is matched or not



194
195
196
# File 'lib/bootinq/component.rb', line 194

def match?(*args)
  @id2name.match?(*args)
end

#module_nameSymbol

Returns:

  • (Symbol)


46
47
48
# File 'lib/bootinq/component.rb', line 46

def module_name
  @id2name.camelcase.to_sym
end

#mountable?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/bootinq/component.rb', line 41

def mountable?
  false
end

#namespaceModule

Returns:

  • (Module)


51
52
53
# File 'lib/bootinq/component.rb', line 51

def namespace
  Object.const_get(module_name)
end

#nextBootinq::Component

Returns new instance with the next #intern.

Returns:

See Also:

  • Symbol#next


255
256
257
# File 'lib/bootinq/component.rb', line 255

def next
  self.class.new(@intern.next)
end

#slice(*args) ⇒ Object Also known as: []

Element reference

See Also:

  • String#slice


211
212
213
# File 'lib/bootinq/component.rb', line 211

def slice(*args)
  @id2name[*args]
end

#succBootinq::Component

Returns new instance with the successor #intern.

Returns:

See Also:

  • Symbol#succ


249
250
251
# File 'lib/bootinq/component.rb', line 249

def succ
  self.class.new(@intern.succ)
end

#swapcaseBootinq::Component

Returns new instance with swapcased #intern.

Returns:

See Also:

  • Symbol#swapcase


243
244
245
# File 'lib/bootinq/component.rb', line 243

def swapcase
  self.class.new(@intern.swapcase)
end

#to_procProc

Returns responded to the given method by #intern.

Returns:

  • (Proc)

    responded to the given method by #intern



146
147
148
# File 'lib/bootinq/component.rb', line 146

def to_proc
  @intern.to_proc
end

#upcaseBootinq::Component

Returns new instance with upcased #intern.

Returns:

See Also:

  • Symbol#upcase


225
226
227
# File 'lib/bootinq/component.rb', line 225

def upcase
  self.class.new(@intern.upcase)
end