Class: SafeYAML::Parse::Sexagesimal

### Home Classes Methods

### In Files

- lib/safe_yaml/parse/sexagesimal.rb

### Parent

Object

### Methods

- ::value

### Class/Module Index

Quicksearch

- SafeYAML
- SafeYAML::Deep
- SafeYAML::LibyamlChecker
- SafeYAML::Parse
- SafeYAML::Parse::Date
- SafeYAML::Parse::Hexadecimal
- SafeYAML::Parse::Sexagesimal
- SafeYAML::PsychHandler
- SafeYAML::PsychResolver
- SafeYAML::Resolver
- SafeYAML::SafeToRubyVisitor
- SafeYAML::SyckResolver
- SafeYAML::Transform
- SafeYAML::Transform::ToBoolean
- SafeYAML::Transform::ToDate
- SafeYAML::Transform::ToFloat
- SafeYAML::Transform::ToInteger
- SafeYAML::Transform::ToNil
- SafeYAML::Transform::ToSymbol
- SafeYAML::Transform::TransformationMap
- SafeYAML::Transform::TransformationMap::CaseAgnosticMap
- SafeYAML::Transform::TransformationMap::ClassMethods
- Object
- YAML

No matching classes.

# SafeYAML::Parse::Sexagesimal

### Constants

FLOAT_MATCHER
INTEGER_MATCHER

### Public Class Methods

value(value) click to toggle source

    # File lib/safe_yaml/parse/sexagesimal.rb, line 7
    def self.value(value)
      before_decimal, after_decimal = value.split(".")

      whole_part = 0
      multiplier = 1

      before_decimal = before_decimal.split(":")
      until before_decimal.empty?
        whole_part += (Float(before_decimal.pop) * multiplier)
        multiplier *= 60
      end

      result = whole_part
      result += Float("." + after_decimal) unless after_decimal.nil?
      result *= -1 if value[0] == "-"
      result
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.