Class: FFI::Clang::Comment

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ffi/clang/comment.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(comment) ⇒ Comment

Returns a new instance of Comment.



57
58
59
# File 'lib/ffi/clang/comment.rb', line 57

def initialize(comment)
	@comment = comment
end

Class Method Details

.build_from(comment) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ffi/clang/comment.rb', line 19

def self.build_from(comment)
	kind = Lib.comment_get_kind(comment)
	case kind
	when :comment_null
		Comment.new comment
	when :comment_text
		TextComment.new comment
	when :comment_inline_command
		InlineCommandComment.new comment
	when :comment_html_start_tag
		HTMLStartTagComment.new comment
	when :comment_html_end_tag
		HTMLEndTagComment.new comment
	when :comment_paragraph
		ParagraphComment.new comment
	when :comment_block_command
		BlockCommandComment.new comment
	when :comment_param_command
		ParamCommandComment.new comment
	when :comment_tparam_command
		TParamCommandComment.new comment
	when :comment_verbatim_block_command
		VerbatimBlockCommandComment.new comment
	when :comment_verbatim_block_line
		VerbatimBlockLineComment.new comment
	when :comment_verbatim_line
		VerbatimLine.new comment
	when :comment_full
		FullComment.new comment
	else
		raise NotImplementedError, kind
	end
end

Instance Method Details

#child(n = 0) ⇒ Object



69
70
71
# File 'lib/ffi/clang/comment.rb', line 69

def child(n = 0)
	Comment.build_from Lib.comment_get_child(@comment, n)
end

#childrenObject



73
74
75
# File 'lib/ffi/clang/comment.rb', line 73

def children
	num_children.times.map { |i| child(i) }
end

#each(&block) ⇒ Object



85
86
87
88
89
# File 'lib/ffi/clang/comment.rb', line 85

def each(&block)
	num_children.times.map do |i|
		block.call(child(i))
	end
end

#has_trailing_newline?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/ffi/clang/comment.rb', line 81

def has_trailing_newline?
	Lib.inline_content_comment_has_trailing_newline(@comment) != 0
end

#kindObject



61
62
63
# File 'lib/ffi/clang/comment.rb', line 61

def kind
	Lib.comment_get_kind(@comment)
end

#num_childrenObject



65
66
67
# File 'lib/ffi/clang/comment.rb', line 65

def num_children
	Lib.comment_get_num_children(@comment)
end

#textObject



53
54
55
# File 'lib/ffi/clang/comment.rb', line 53

def text
	return ""
end

#whitespace?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/ffi/clang/comment.rb', line 77

def whitespace?
	Lib.comment_is_whitespace(@comment) != 0
end