Class: CC::Yaml::Nodes::Language

Inherits:
Scalar show all
Defined in:
lib/cc/yaml/nodes/language.rb

Constant Summary collapse

LANGUAGES =
%w[Ruby JavaScript Python PHP].freeze

Instance Attribute Summary

Attributes inherited from Scalar

#value

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from Scalar

#!@, #==, [], cast, #cast, #cast?, cast?, default, #default_type, default_type, #each_scalar, #empty?, has_default?, #inspect, #prepare, #visit_child, #visit_scalar, #visit_sequence, #with_value, #with_value!

Methods inherited from Node

#deep_verify, #dup, #error, #errors, #errors?, has_default?, #initialize, #method_missing, #nested_warning, #nested_warnings, #prepare, #respond_to_missing?, #to_json, #to_s, #verify, #visit_child, #visit_mapping, #visit_pair, #visit_scalar, #visit_sequence, #visit_unexpected, #warning, #warnings, #warnings?, #with_value

Constructor Details

This class inherits a constructor from CC::Yaml::Nodes::Node

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CC::Yaml::Nodes::Node

Instance Method Details

#appears_to_be_mispelled_version_of?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/cc/yaml/nodes/language.rb', line 15

def appears_to_be_mispelled_version_of?
  if !valid? && downcased_language_map.has_key?(name.downcase)
    downcased_language_map[self]
  else
    false
  end
end

#downcased_language_mapObject



23
24
25
26
27
28
# File 'lib/cc/yaml/nodes/language.rb', line 23

def downcased_language_map
  @downcased_language_map ||=
  LANGUAGES.each_with_object({}) do |language, obj|
    obj[language.downcase] = language
  end
end

#nameObject



11
12
13
# File 'lib/cc/yaml/nodes/language.rb', line 11

def name
  to_s
end

#valid?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/cc/yaml/nodes/language.rb', line 7

def valid?
  LANGUAGES.include?(name)
end