Module: GetText::ClassInfo

### Home Classes Methods

### In Files

- lib/gettext/class_info.rb

### Methods

- #normalize_class
- #related_classes
- #related_classes_internal

### Included Modules

- Locale::Util::Memoizable

### Class/Module Index

Quicksearch

- GetText
- GetText::ClassInfo
- GetText::ErbParser
- GetText::GladeParser
- GetText::LocalePath
- GetText::MO
- GetText::MO::HeaderRev1
- GetText::MO::InvalidFormat
- GetText::NoboundTextDomainError
- GetText::PO
- GetText::PO::NonExistentEntryError
- GetText::POEntry
- GetText::POEntry::InvalidTypeError
- GetText::POEntry::NoMsgctxtError
- GetText::POEntry::NoMsgidError
- GetText::POEntry::NoMsgidPluralError
- GetText::POEntryForRubyParser
- GetText::POParser
- GetText::ParseError
- GetText::RubyParser
- GetText::TextDomain
- GetText::TextDomainGroup
- GetText::TextDomainManager
- GetText::Tools
- GetText::Tools::MsgInit
- GetText::Tools::MsgInit::ArgumentError
- GetText::Tools::MsgInit::Error
- GetText::Tools::MsgInit::ValidationError
- GetText::Tools::MsgMerge
- GetText::Tools::Task
- GetText::Tools::XGetText

No matching classes.

# GetText::ClassInfo

For normalize/finding the related classes/modules. This is used for realizing the scope of TextDomain. (see: www.yotabanana.com/hiki/ruby-gettext-scope.html)

### Public Instance Methods

normalize_class(klass) click to toggle source

normalize the class name klass should kind of the class, not object.

    # File lib/gettext/class_info.rb, line 14
    def normalize_class(klass)
      ret = (klass.kind_of? Module) ? klass : klass.class
      if ret.name =~ /^\#<|^$/ or ret == GetText or ret.name.nil?
        ret = Object
      end
      ret
    end

related_classes(klass, all_classes = []) click to toggle source

Returns the classes which related to klass (klass's ancestors, included modules and nested modules)

    # File lib/gettext/class_info.rb, line 59
    def related_classes(klass, all_classes = [])
      ret = related_classes_internal(klass, all_classes)
      unless ret.include? Object
        ret += [Object]
      end
      ret
    end

related_classes_internal(klass, all_classes = [], analyzed_classes = [] ) click to toggle source

Internal method for related_classes.

    # File lib/gettext/class_info.rb, line 28
    def related_classes_internal(klass, all_classes = [], analyzed_classes = [] )
      ret = []
      klass = normalize_class(klass)

      return [Object] if root_ancestors.include? klass

      ary = klass.name.split(/::/)
      while(v = ary.shift)
        ret.unshift(((ret.size == 0) ? Object.const_get(v) : ret[0].const_get(v)))
      end
      ret -= analyzed_classes
      if ret.size > 1
        ret += related_classes_internal(ret[1], all_classes, analyzed_classes)
        ret.uniq!
      end
      analyzed_classes << klass unless analyzed_classes.include? klass

      klass.ancestors[1..-1].each do |a|
        ret += related_classes_internal(a, all_classes, analyzed_classes)
        ret.uniq!
      end

      if all_classes.size > 0
        (ret & all_classes).uniq
      else
        ret.uniq
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.